# HG changeset patch # User Richard M. Stallman # Date 804533491 0 # Node ID 92440abe84096e8345e89a06571150e0ac5155aa # Parent 74e5ebf071fb433fb4886d13b711ee59ab9a85b2 (sendmail-send-it): If user-full-name contains special characters, quote or escape them for the From: line. diff -r 74e5ebf071fb -r 92440abe8409 lisp/mail/sendmail.el --- a/lisp/mail/sendmail.el Fri Jun 30 10:38:19 1995 +0000 +++ b/lisp/mail/sendmail.el Fri Jun 30 17:31:31 1995 +0000 @@ -519,9 +519,31 @@ (let* ((login (user-login-name)) (fullname (user-full-name))) (cond ((eq mail-from-style 'angles) - (insert "From: " fullname " <" login ">\n")) + (insert "From: " fullname) + (let ((fullname-start (+ (point-min) 6)) + (fullname-end (point-marker))) + (goto-char fullname-start) + ;; Look for a character that cannot appear unquoted + ;; according to RFC 822. + (if (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]" + fullname-end 1) + (progn + ;; Quote fullname, escaping specials. + (goto-char fullname-start) + (insert "\"") + (while (re-search-forward "[\"\\]" + fullname-end 1) + (replace-match "\\\\\\&" t)) + (insert "\"")))) + (insert " <" login ">\n")) ((eq mail-from-style 'parens) - (insert "From: " login " (" fullname ")\n")) + (insert "From: " login " (" fullname) + (let ((fullname-end (point-marker))) + (backward-char (length fullname)) + ;; RFC 822 says ()\ must be escaped in comments. + (while (re-search-forward "[()\\]" fullname-end 1) + (replace-match "\\\\\\&" t))) + (insert ")\n")) ((null mail-from-style) (insert "From: " login "\n"))))) ;; Insert an extra newline if we need it to work around