aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-06-30 17:31:31 +0000
committerRichard M. Stallman1995-06-30 17:31:31 +0000
commit7f1d5de23df6dd4dd1f3add81c0cb3c82dddc673 (patch)
tree460940cfb62e387b0c3d27c21214712c81959029
parent2eec96b217e3358ac7cdbb8aabba9ad68e973cd9 (diff)
downloademacs-7f1d5de23df6dd4dd1f3add81c0cb3c82dddc673.tar.gz
emacs-7f1d5de23df6dd4dd1f3add81c0cb3c82dddc673.zip
(sendmail-send-it): If user-full-name contains
special characters, quote or escape them for the From: line.
-rw-r--r--lisp/mail/sendmail.el26
1 files changed, 24 insertions, 2 deletions
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 15a7096814c..f30581cbb2a 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -519,9 +519,31 @@ the user from the mailer."
519 (let* ((login (user-login-name)) 519 (let* ((login (user-login-name))
520 (fullname (user-full-name))) 520 (fullname (user-full-name)))
521 (cond ((eq mail-from-style 'angles) 521 (cond ((eq mail-from-style 'angles)
522 (insert "From: " fullname " <" login ">\n")) 522 (insert "From: " fullname)
523 (let ((fullname-start (+ (point-min) 6))
524 (fullname-end (point-marker)))
525 (goto-char fullname-start)
526 ;; Look for a character that cannot appear unquoted
527 ;; according to RFC 822.
528 (if (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]"
529 fullname-end 1)
530 (progn
531 ;; Quote fullname, escaping specials.
532 (goto-char fullname-start)
533 (insert "\"")
534 (while (re-search-forward "[\"\\]"
535 fullname-end 1)
536 (replace-match "\\\\\\&" t))
537 (insert "\""))))
538 (insert " <" login ">\n"))
523 ((eq mail-from-style 'parens) 539 ((eq mail-from-style 'parens)
524 (insert "From: " login " (" fullname ")\n")) 540 (insert "From: " login " (" fullname)
541 (let ((fullname-end (point-marker)))
542 (backward-char (length fullname))
543 ;; RFC 822 says ()\ must be escaped in comments.
544 (while (re-search-forward "[()\\]" fullname-end 1)
545 (replace-match "\\\\\\&" t)))
546 (insert ")\n"))
525 ((null mail-from-style) 547 ((null mail-from-style)
526 (insert "From: " login "\n"))))) 548 (insert "From: " login "\n")))))
527 ;; Insert an extra newline if we need it to work around 549 ;; Insert an extra newline if we need it to work around