diff options
author | Eli Zaretskii <eliz@gnu.org> | 2022-12-19 19:01:04 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2022-12-19 12:49:59 -0500 |
commit | ae9bfed50dbf5043c0b47f20473ef43d8aeebebd (patch) | |
tree | 562cfe6219fd8d34890b6f3aef62abd7de3d5523 | |
parent | 0636e1066bbafcd8219d9a8e09301c77f875d78b (diff) | |
download | emacs-ae9bfed50dbf5043c0b47f20473ef43d8aeebebd.tar.gz |
Fix storing email into nnmail by Gnus
Backporting suggested by Florian Weimer, since this is
a denial-of-service issue.
* 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 <fweimer@redhat.com>.
(cherry picked from commit 23f7c9c2a92e4619b7c4d2286d4249f812cd695d)
-rw-r--r-- | lisp/gnus/nnml.el | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lisp/gnus/nnml.el b/lisp/gnus/nnml.el index afdb0c780a5..258c5efc79f 100644 --- a/lisp/gnus/nnml.el +++ b/lisp/gnus/nnml.el @@ -775,17 +775,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 |