rfc2047-quote-special-characters-in-quoted-strings): Fix backslashes handling.
authorKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 7 Sep 2006 12:00:43 +0000 (12:00 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Thu, 7 Sep 2006 12:00:43 +0000 (12:00 +0000)
lisp/ChangeLog
lisp/rfc2047.el

index a81366f..44fc8c0 100644 (file)
@@ -1,7 +1,7 @@
 2006-09-07  Katsumi Yamaoka  <yamaoka@jpl.org>
 
-       * rfc2047.el (rfc2047-quote-special-characters-in-quoted-strings):
-       Fix the way to find boundaries of quoted strings.
+       * rfc2047.el (rfc2047-quote-special-characters-in-quoted-strings): Fix
+       backslashes handling and the way to find boundaries of quoted strings.
 
 2006-09-07  Daiki Ueno  <ueno@unixuser.org>
 
index 97bcc5d..b3a9c2d 100644 (file)
@@ -149,32 +149,32 @@ Quoting will not be done in a quoted string if it contains characters
 matching ENCODABLE-REGEXP."
   (goto-char (point-min))
   (let ((tspecials (concat "[" ietf-drums-tspecials "]"))
-       beg)
+       beg end)
     (with-syntax-table (standard-syntax-table)
       (while (search-forward "\"" nil t)
-       (unless (eq (char-before) ?\\)
-         (setq beg (match-end 0))
-         (goto-char (match-beginning 0))
+       (setq beg (match-beginning 0))
+       (unless (eq (char-before beg) ?\\)
+         (goto-char beg)
+         (setq beg (1+ beg))
          (condition-case nil
              (progn
                (forward-sexp)
-               (save-restriction
-                 (narrow-to-region beg (1- (point)))
-                 (goto-char beg)
-                 (unless (and encodable-regexp
-                              (re-search-forward encodable-regexp nil t))
-                   (while (re-search-forward tspecials nil t)
-                     (unless (and (eq (char-before) ?\\) ;; Already quoted.
-                                  (looking-at tspecials))
+               (setq end (1- (point)))
+               (goto-char beg)
+               (if (and encodable-regexp
+                        (re-search-forward encodable-regexp end t))
+                   (goto-char (1+ end))
+                 (save-restriction
+                   (narrow-to-region beg end)
+                   (while (re-search-forward tspecials nil 'move)
+                     (if (eq (char-before) ?\\)
+                         (if (looking-at tspecials) ;; Already quoted.
+                             (forward-char)
+                           (insert "\\"))
                        (goto-char (match-beginning 0))
-                       (unless (or (eq (char-before) ?\\)
-                                   (and rfc2047-encode-encoded-words
-                                        (eq (char-after) ??)
-                                        (eq (char-before) ?=)))
-                         (insert "\\"))
+                       (insert "\\")
                        (forward-char))))
-                 (goto-char (point-max)))
-               (forward-char))
+                 (forward-char)))
            (error
             (goto-char beg))))))))