summaryrefslogtreecommitdiff
path: root/lisp/mail
diff options
context:
space:
mode:
authorKatsumi Yamaoka <yamaoka@jpl.org>2019-11-14 08:27:58 +0000
committerKatsumi Yamaoka <yamaoka@jpl.org>2019-11-14 08:27:58 +0000
commit4f45e89852129db6a3026187768c6ba5b30c39fe (patch)
treeec2b06fa721f40ed033c1d47f237a4399079676c /lisp/mail
parent7a1f401b8341f363f2c6b9e58344dc2738259ddc (diff)
downloademacs-4f45e89852129db6a3026187768c6ba5b30c39fe.tar.gz
Obsolete rfc2047-quote-special-characters-in-quoted-strings (bug#38200)
* lisp/mail/rfc2047.el (rfc2047-quote-special-characters-in-quoted-strings): Make obsolete instead of removing it.
Diffstat (limited to 'lisp/mail')
-rw-r--r--lisp/mail/rfc2047.el50
1 files changed, 50 insertions, 0 deletions
diff --git a/lisp/mail/rfc2047.el b/lisp/mail/rfc2047.el
index 8229bebfd67..d8511d4e394 100644
--- a/lisp/mail/rfc2047.el
+++ b/lisp/mail/rfc2047.el
@@ -184,6 +184,56 @@ This is either `base64' or `quoted-printable'."
(re-search-forward ":[ \t\n]*" nil t)
(buffer-substring-no-properties (point) (point-max)))))
+(make-obsolete 'rfc2047-quote-special-characters-in-quoted-strings nil "27.1")
+(defun rfc2047-quote-special-characters-in-quoted-strings (&optional
+ encodable-regexp)
+ "Quote special characters with `\\'s in quoted strings.
+Quoting will not be done in a quoted string if it contains characters
+matching ENCODABLE-REGEXP or it is within parentheses."
+ (goto-char (point-min))
+ (let ((tspecials (concat "[" ietf-drums-tspecials "]"))
+ (start (point))
+ beg end)
+ (with-syntax-table (standard-syntax-table)
+ (while (not (eobp))
+ (if (ignore-errors
+ (forward-list 1)
+ (eq (char-before) ?\)))
+ (forward-list -1)
+ (goto-char (point-max)))
+ (save-restriction
+ (narrow-to-region start (point))
+ (goto-char start)
+ (while (search-forward "\"" nil t)
+ (setq beg (match-beginning 0))
+ (unless (eq (char-before beg) ?\\)
+ (goto-char beg)
+ (setq beg (1+ beg))
+ (condition-case nil
+ (progn
+ (forward-sexp)
+ (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))
+ (insert "\\")
+ (forward-char))))
+ (forward-char)))
+ (error
+ (goto-char beg)))))
+ (goto-char (point-max)))
+ (forward-list 1)
+ (setq start (point))))))
+
(defvar rfc2047-encoding-type 'address-mime
"The type of encoding done by `rfc2047-encode-region'.
This should be dynamically bound around calls to