From ef14acfb68bb5b0ce42221e9681b93562f8085eb Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Fri, 22 Jan 2021 19:07:52 +0100 Subject: [PATCH] Make nnml handle invalid non-ASCII headers more consistently * lisp/gnus/nnml.el (nnml--encode-headers): New function to RFC2047-encode invalid Subject/From headers (bug#45925). This will make them be displayed more consistently in the Summary buffer (but still "wrong" sometimes, since there's not that much we can guess at at this stage, charset wise). (nnml-parse-head): Use it. --- lisp/gnus/nnml.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lisp/gnus/nnml.el b/lisp/gnus/nnml.el index ebececa3ce2..3cdfc749703 100644 --- a/lisp/gnus/nnml.el +++ b/lisp/gnus/nnml.el @@ -769,8 +769,24 @@ article number. This function is called narrowed to an article." (let ((headers (nnheader-parse-head t))) (setf (mail-header-chars headers) chars) (setf (mail-header-number headers) number) + ;; If there's non-ASCII raw characters in the data, + ;; RFC2047-encode them to avoid having arbitrary data in the + ;; .overview file. + (nnml--encode-headers headers) headers)))) +(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 ((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))))) + (defun nnml-get-nov-buffer (group &optional incrementalp) (let ((buffer (gnus-get-buffer-create (format " *nnml %soverview %s*" -- 2.39.5