From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14186 invoked from network); 18 Dec 2022 16:33:29 -0000 Received: from mx1.math.uh.edu (129.7.128.32) by inbox.vuxu.org with ESMTPUTF8; 18 Dec 2022 16:33:29 -0000 Received: from lists1.math.uh.edu ([129.7.128.208]) by mx1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1p6wbQ-009KuD-9j for ml@inbox.vuxu.org; Sun, 18 Dec 2022 10:33:28 -0600 Received: from lists1.math.uh.edu ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.96) (envelope-from ) id 1p6wbQ-004X7r-09 for ml@inbox.vuxu.org; Sun, 18 Dec 2022 10:33:28 -0600 Received: from mx1.math.uh.edu ([129.7.128.32]) by lists1.math.uh.edu with esmtp (Exim 4.96) (envelope-from ) id 1p6RtI-004UNU-2v for ding@lists.math.uh.edu; Sat, 17 Dec 2022 01:45:54 -0600 Received: from quimby.gnus.org ([95.216.78.240]) by mx1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1p6RtG-008TQP-MS for ding@lists.math.uh.edu; Sat, 17 Dec 2022 01:45:52 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-type:MIME-version:References :Subject:In-Reply-To:CC:To:From:Message-Id:Date:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3UXTzLfMtlVE9SAHTnBeIKGSI/BTsxsth6ZMBIJQdwQ=; b=aYshzcLvAPyNWwdbhLmOxJx3Ma pnBxjIxbKveeGV8pc2U5Upn4tIwHAUJA3YCV5VE8Koa3EQaSVG+88cNTfays+hRGqObGF4UX8bTiW t7ymuFMCbVRZI5Ywy0BWmc4UqNzQiu/NgD+ufijIU2FsqBq0Err7onuQbj23cs3a8+BQ=; Received: from eggs.gnu.org ([2001:470:142:3::10]) by quimby.gnus.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p6Rt6-000370-Sq; Sat, 17 Dec 2022 08:45:44 +0100 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6Rt3-0001uE-2L; Sat, 17 Dec 2022 02:45:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=3UXTzLfMtlVE9SAHTnBeIKGSI/BTsxsth6ZMBIJQdwQ=; b=iS1nogm57xiNnKxTM5v8 oqSx15FLrISophvV5BpeMUofm8++W2lVDeCssbKygNtA8G8mJAn0U7fPImhLx0bp90qcUyg8eCsg4 vX2EVAWs3Cp0egV7NWRkPomFn2pQGykxrswEEhGU9DNA0oyvzYP0faR0NbGuyBg0LC5sxZ/eLDVtd ok2gOMAVoGoIBLZLsOBClbddEu0aEMd4y9yhsyc2tLybevVxyLjIhxRW4I1qDISKVOSa/pfMFL2/L sSLUwNHvHRnPoL2mkO1qCVscS7sM0+GeVbZKnLergc1P4FuSzJcXahc+NxOjZpb6wCPY0fWmBs8WK a8HiKG731Is2uA==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6Rt2-0004qI-Hr; Sat, 17 Dec 2022 02:45:36 -0500 Date: Sat, 17 Dec 2022 09:45:40 +0200 Message-Id: <83k02qiicb.fsf@gnu.org> From: Eli Zaretskii To: Florian Weimer CC: Lars Ingebrigtsen , Eric Abrahamsen , emacs-devel@gnu.org, ding@gnus.org In-Reply-To: <874jtvq8c2.fsf@oldenburg.str.redhat.com> (message from Florian Weimer on Fri, 16 Dec 2022 23:42:21 +0100) Subject: Re: master ef14acf: Make nnml handle invalid non-ASCII headers more consistently References: <20210122180801.14756.84264@vcs0.savannah.gnu.org> <20210122180802.F0A1E20A10@vcs0.savannah.gnu.org> <874jtvq8c2.fsf@oldenburg.str.redhat.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit List-ID: Precedence: bulk > From: Florian Weimer > Cc: Lars Ingebrigtsen , ding@gnus.org > Date: Fri, 16 Dec 2022 23:42:21 +0100 > > * Lars Ingebrigtsen: > > > branch: master > > commit ef14acfb68bb5b0ce42221e9681b93562f8085eb > > Author: Lars Ingebrigtsen > > Commit: Lars Ingebrigtsen > > > > 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 ebececa..3cdfc74 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)))) > > Unfortunately, this change in particular causes Gnus to stops storing > messages into nnmail after receiving a message with this header: > > From: =?utf-8?b?572X5YuH5YiaKFlvbmdnYW5nIEx1bykgdmlhIEVsZnV0aWxzLWRldmVs?= > > > The logged error message is: > > Mail source (maildir :path …) failed: (error Invalid data for rfc2047 encoding: 罗勇刚(Yonggang Luo) via Elfutils-devel ) > > On an older Emacs without this change, it seems that the original header > is written to the .overview file, which sidestep the problem that not > all strings are encodable by the rfc2047 functions. Thanks. I guess this From header is invalid because there's no space between the "罗勇刚" and the "(Yonggang Luo)" parts? Does the naïve patch below solve the problem? diff --git a/lisp/gnus/nnml.el b/lisp/gnus/nnml.el index 40e4b9e..7aa445e 100644 --- a/lisp/gnus/nnml.el +++ b/lisp/gnus/nnml.el @@ -776,17 +776,22 @@ nnml-parse-head (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