diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2017-01-27 13:53:47 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2017-01-27 13:54:50 +0100 |
commit | 03c1080cd4c9b45fc9b7467e156085d4fce446a4 (patch) | |
tree | 9ed61e17fb441ce89c98bfd77c7d3159215cfc2f /lisp/gnus/mml.el | |
parent | 90c76346740c097063b4a273ceb3af01327ff2a4 (diff) | |
download | emacs-03c1080cd4c9b45fc9b7467e156085d4fce446a4.tar.gz |
Fix charsets and encodings from non-file MIME parts
* lisp/gnus/mml.el (mml-generate-mime-1): Get the charsets and
encoding right for parts that do not originate from files.
Diffstat (limited to 'lisp/gnus/mml.el')
-rw-r--r-- | lisp/gnus/mml.el | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el index a0ca624909f..3a31349d378 100644 --- a/lisp/gnus/mml.el +++ b/lisp/gnus/mml.el @@ -612,25 +612,32 @@ be \"related\" or \"alternate\"." (with-temp-buffer (set-buffer-multibyte nil) ;; First insert the data into the buffer. - (cond - ((cdr (assq 'buffer cont)) - (insert-buffer-substring (cdr (assq 'buffer cont)))) - ((and filename - (not (equal (cdr (assq 'nofile cont)) "yes"))) - (mm-insert-file-contents filename)) - ((eq 'mml (car cont)) - (insert (cdr (assq 'contents cont)))) - (t - (save-restriction - (narrow-to-region (point) (point)) - (insert (cdr (assq 'contents cont))) - ;; Remove quotes from quoted tags. - (goto-char (point-min)) - (while (re-search-forward - "<#!+/?\\(part\\|multipart\\|external\\|mml\\|secure\\)" - nil t) - (delete-region (+ (match-beginning 0) 2) - (+ (match-beginning 0) 3)))))) + (if (and filename + (not (equal (cdr (assq 'nofile cont)) "yes"))) + (mm-insert-file-contents filename) + (insert + (with-temp-buffer + (cond + ((cdr (assq 'buffer cont)) + (insert-buffer-substring (cdr (assq 'buffer cont)))) + ((eq 'mml (car cont)) + (insert (cdr (assq 'contents cont)))) + (t + (insert (cdr (assq 'contents cont))) + ;; Remove quotes from quoted tags. + (goto-char (point-min)) + (while (re-search-forward + "<#!+/?\\(part\\|multipart\\|external\\|mml\\|secure\\)" + nil t) + (delete-region (+ (match-beginning 0) 2) + (+ (match-beginning 0) 3))))) + (setq charset + (mm-coding-system-to-mime-charset + (detect-coding-region + (point-min) (point-max) t))) + (encode-coding-region (point-min) (point-max) + charset) + (buffer-string)))) (cond ((eq (car cont) 'mml) (let ((mml-boundary (mml-compute-boundary cont)) |