aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-07-01 00:33:52 +0000
committerRichard M. Stallman1995-07-01 00:33:52 +0000
commit7dad528a116991316f2e72720c435e4be23dea1a (patch)
tree11f6487b53647d6d51c06d7ba7e8e05e1a3ed851
parentb0d77652d3ffe47474fc9e401fe1096da6230c79 (diff)
downloademacs-7dad528a116991316f2e72720c435e4be23dea1a.tar.gz
emacs-7dad528a116991316f2e72720c435e4be23dea1a.zip
(sendmail-send-it): If mail-from-style is parens,
don't escape all parentheses; escape only the nonmatching ones.
-rw-r--r--lisp/mail/sendmail.el24
1 files changed, 18 insertions, 6 deletions
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index f30581cbb2a..f54b52cb4b5 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -537,12 +537,24 @@ the user from the mailer."
537 (insert "\"")))) 537 (insert "\""))))
538 (insert " <" login ">\n")) 538 (insert " <" login ">\n"))
539 ((eq mail-from-style 'parens) 539 ((eq mail-from-style 'parens)
540 (insert "From: " login " (" fullname) 540 (insert "From: " login " (")
541 (let ((fullname-end (point-marker))) 541 (let ((fullname-start (point)))
542 (backward-char (length fullname)) 542 (insert fullname)
543 ;; RFC 822 says ()\ must be escaped in comments. 543 (let ((fullname-end (point-marker)))
544 (while (re-search-forward "[()\\]" fullname-end 1) 544 (goto-char fullname-start)
545 (replace-match "\\\\\\&" t))) 545 ;; RFC 822 says \ and nonmatching parentheses
546 ;; must be escaped in comments.
547 ;; Escape every instance of ()\ ...
548 (while (re-search-forward "[()\\]" fullname-end 1)
549 (replace-match "\\\\\\&" t))
550 ;; ... then undo escaping of matching parentheses,
551 ;; including matching nested parentheses.
552 (goto-char fullname-start)
553 (while (re-search-forward
554 "\\(\\=\\|[^\\]\\(\\\\\\\\\\)*\\)\\\\(\\(\\([^\\]\\|\\\\\\\\\\)*\\)\\\\)"
555 fullname-end 1)
556 (replace-match "\\1(\\3)" t)
557 (goto-char fullname-start))))
546 (insert ")\n")) 558 (insert ")\n"))
547 ((null mail-from-style) 559 ((null mail-from-style)
548 (insert "From: " login "\n"))))) 560 (insert "From: " login "\n")))))