From 3a4fc8d006e21b115fb64734158b10f8f4591f25 Mon Sep 17 00:00:00 2001 From: Katsumi Yamaoka Date: Thu, 7 Sep 2006 12:00:43 +0000 Subject: [PATCH] rfc2047-quote-special-characters-in-quoted-strings): Fix backslashes handling. --- lisp/ChangeLog | 4 ++-- lisp/rfc2047.el | 38 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a81366fac..44fc8c0ae 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,7 +1,7 @@ 2006-09-07 Katsumi Yamaoka - * 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 diff --git a/lisp/rfc2047.el b/lisp/rfc2047.el index 97bcc5d72..b3a9c2dee 100644 --- a/lisp/rfc2047.el +++ b/lisp/rfc2047.el @@ -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)))))))) -- 2.25.1