(rfc2047-decode-region): Don't quote decoded words containing tspecial
authorKatsumi Yamaoka <yamaoka@jpl.org>
Tue, 17 Nov 2009 02:22:49 +0000 (02:22 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Tue, 17 Nov 2009 02:22:49 +0000 (02:22 +0000)
 characters if they have been already quoted.

lisp/ChangeLog
lisp/rfc2047.el

index 5013d38..51d4b1c 100644 (file)
@@ -1,3 +1,8 @@
+2009-11-17  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * rfc2047.el (rfc2047-decode-region): Don't quote decoded words
+       containing tspecial characters if they have been already quoted.
+
 2009-11-05  Dan Nicolaescu  <dann@ics.uci.edu>
 
        * dns-mode.el (auto-mode-alist): Purecopy string.
index 4ba4bcb..78c03b4 100644 (file)
@@ -1026,6 +1026,7 @@ other than `\"' and `\\' in quoted strings."
            ;; things essentially must not be there.
            (while (re-search-forward "[\n\r]+" nil t)
              (replace-match " "))
+           (setq end (point-max))
            ;; Quote decoded words if there are special characters
            ;; which might violate RFC2822.
            (when (and rfc2047-quote-decoded-words-containing-tspecials
@@ -1035,10 +1036,15 @@ other than `\"' and `\\' in quoted strings."
                         (when regexp
                           (save-restriction
                             (widen)
-                            (beginning-of-line)
-                            (while (and (memq (char-after) '(?  ?\t))
-                                        (zerop (forward-line -1))))
-                            (looking-at regexp)))))
+                            (and
+                             ;; Don't quote words if already quoted.
+                             (not (and (eq (char-before e) ?\")
+                                       (eq (char-after end) ?\")))
+                             (progn
+                               (beginning-of-line)
+                               (while (and (memq (char-after) '(?  ?\t))
+                                           (zerop (forward-line -1))))
+                               (looking-at regexp)))))))
              (let (quoted)
                (goto-char e)
                (skip-chars-forward " \t")