(rfc2047-encode-region): Treat backslash-quoted characters as non-special.
authorKatsumi Yamaoka <yamaoka@jpl.org>
Mon, 12 Jul 2004 02:57:03 +0000 (02:57 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Mon, 12 Jul 2004 02:57:03 +0000 (02:57 +0000)
lisp/ChangeLog
lisp/rfc2047.el

index 248c088..2de7d32 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-12  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * rfc2047.el (rfc2047-encode-region): Treat backslash-quoted
+       characters as non-special.
+
 2004-07-09  Simon Josefsson  <jas@extundo.com>
 
        * gnus-agent.el (gnus-agent-synchronize-flags): Revert to ask.
index a904584..e88e93e 100644 (file)
@@ -292,7 +292,7 @@ Dynamically bind `rfc2047-encoding-type' to change that."
                                "[^\000-\177]+\\|=\\?"
                              "[^\000-\177]+"))
          start                         ; start of current token
-         end begin
+         end begin csyntax
          ;; Whether there's an encoded word before the current token,
          ;; either immediately or separated by space.
          last-encoded
@@ -330,7 +330,7 @@ Dynamically bind `rfc2047-encoding-type' to change that."
                (cond
                 ((not (char-after)))   ; eob
                 ;; else token start
-                ((eq ?\" (char-syntax (char-after)))
+                ((eq ?\" (setq csyntax (char-syntax (char-after))))
                  ;; Quoted word.
                  (forward-sexp)
                  (setq end (point))
@@ -357,14 +357,14 @@ Dynamically bind `rfc2047-encoding-type' to change that."
                        (rfc2047-encode start (- end 2))
                        (setq last-encoded t)) ; record that it was encoded
                    (setq last-encoded  nil)))
-                ((eq ?. (char-syntax (char-after)))
+                ((eq ?. csyntax)
                  ;; Skip other delimiters, but record that they've
                  ;; potentially separated quoted words.
                  (forward-char)
                  (setq last-encoded nil))
-                ((eq ?\) (char-syntax (char-after)))
+                ((eq ?\) csyntax)
                  (error "Unbalanced parentheses"))
-                ((eq ?\( (char-syntax (char-after)))
+                ((eq ?\( csyntax)
                  ;; Look for the end of parentheses.
                  (forward-list)
                  ;; Encode text as an unstructured field.
@@ -380,7 +380,13 @@ Dynamically bind `rfc2047-encoding-type' to change that."
                    (when (looking-at "[\000-\177]+")
                      (setq begin (point)
                            end (match-end 0))
-                     (if (re-search-forward "[ \t\n]\\|\\Sw" end 'move)
+                     (if (progn
+                           (while (and (re-search-forward "[ \t\n]\\|\\Sw"
+                                                          end 'move)
+                                       (eq ?\\ (char-syntax (char-before))))
+                             ;; Skip backslash-quoted characters.
+                             (forward-char))
+                           (< (point) end))
                          (progn
                            (setq end (match-beginning 0))
                            (if rfc2047-encode-encoded-words