]> code.delx.au - gnu-emacs/blobdiff - lisp/gnus/rfc2047.el
Merge from gnus--rel--5.10
[gnu-emacs] / lisp / gnus / rfc2047.el
index dc51a104c2ff40c5847ec677708f7e1348c0c4aa..40b10c07eb49cbb2aa780d848bf4ca07989f0dc6 100644 (file)
@@ -178,30 +178,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))
+               (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)
-                     (unless (and (eq (char-before) ?\\) ;; Already quoted.
-                                  (looking-at tspecials))
+                     (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 "\\")))
-                     (forward-char)))))
+                       (insert "\\")
+                       (forward-char))))
+                 (forward-char)))
            (error
             (goto-char beg))))))))
 
@@ -859,7 +861,7 @@ the decoder will fully decode each encoded-word before concatenating
 them.")
 
 (defun rfc2047-strip-backslashes-in-quoted-strings ()
-  "Strip backslashes in quoted strings.  `\\\"' and `\\\\' remain."
+  "Strip backslashes in quoted strings.  `\\\"' remains."
   (goto-char (point-min))
   (let (beg)
     (with-syntax-table (standard-syntax-table)
@@ -874,7 +876,7 @@ them.")
                  (narrow-to-region beg (1- (point)))
                  (goto-char beg)
                  (while (search-forward "\\" nil 'move)
-                   (unless (memq (char-after) '(?\" ?\\))
+                   (unless (memq (char-after) '(?\"))
                      (delete-backward-char 1))
                    (forward-char)))
                (forward-char))