Skip to content

Commit

Permalink
Fix storing email into nnmail by Gnus
Browse files Browse the repository at this point in the history
* lisp/gnus/nnml.el (nnml--encode-headers): Wrap
'rfc2047-encode-string' calls with 'ignore-errors', to avoid
disrupting email workflows due to possibly-invalid headers.
Reported by Florian Weimer <[email protected]>.
  • Loading branch information
Eli-Zaretskii committed Dec 19, 2022
1 parent 63cdbd9 commit 23f7c9c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lisp/gnus/nnml.el
Original file line number Diff line number Diff line change
Expand Up @@ -776,17 +776,22 @@ article number. This function is called narrowed to an article."
(nnml--encode-headers headers)
headers))))

;; RFC2047-encode Subject and From, but leave invalid headers unencoded.
(defun nnml--encode-headers (headers)
(let ((subject (mail-header-subject headers))
(rfc2047-encoding-type 'mime))
(unless (string-match "\\`[[:ascii:]]*\\'" subject)
(setf (mail-header-subject headers)
(mail-encode-encoded-word-string subject t))))
(let ((encoded-subject
(ignore-errors (mail-encode-encoded-word-string subject t))))
(if encoded-subject
(setf (mail-header-subject headers) encoded-subject)))))
(let ((from (mail-header-from headers))
(rfc2047-encoding-type 'address-mime))
(unless (string-match "\\`[[:ascii:]]*\\'" from)
(setf (mail-header-from headers)
(rfc2047-encode-string from t)))))
(let ((encoded-from
(ignore-errors (rfc2047-encode-string from t))))
(if encoded-from
(setf (mail-header-from headers) encoded-from))))))

(defun nnml-get-nov-buffer (group &optional incrementalp)
(let ((buffer (gnus-get-buffer-create
Expand Down

0 comments on commit 23f7c9c

Please sign in to comment.