emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 03c1080: Fix charsets and encodings from non-file M


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 03c1080: Fix charsets and encodings from non-file MIME parts
Date: Fri, 27 Jan 2017 12:54:54 +0000 (UTC)

branch: master
commit 03c1080cd4c9b45fc9b7467e156085d4fce446a4
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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.
---
 lisp/gnus/mml.el |   45 ++++++++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el
index a0ca624..3a31349 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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]