GNU bug report logs - #42029
`gnus-registry-spool-action' gets field beyond message headers

Previous Next

Packages: emacs, gnus;

Reported by: tomotaka.suwa <at> gmail.com

Date: Wed, 24 Jun 2020 11:52:02 UTC

Severity: normal

Tags: fixed

Found in version 5.13

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 42029 in the body.
You can then email your comments to 42029 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#42029; Package emacs,gnus. (Wed, 24 Jun 2020 11:52:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to tomotaka.suwa <at> gmail.com:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org. (Wed, 24 Jun 2020 11:52:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: tomotaka.suwa <at> gmail.com
To: submit <at> debbugs.gnu.org (The Gnus Bugfixing Girls + Boys)
Subject: `gnus-registry-spool-action' gets field beyond message headers
Date: Wed, 24 Jun 2020 20:49:03 +0900
Hi,

I've been suffering from `mail-source-crash-box' on getting new mail.

After some debug and investigation, I noticed that
`mail-extract-address-components' was failing by invalid addresses.

The issue happened in `gnus-registry-spool-action' and invalid addresses
are passed by calling `message-fetch-field' on the buffer not narrowed
to message headers.

Below snippet reproduce the root issue:

(with-temp-buffer
  (save-excursion
    ;; mail header
    (insert "From: from <at> bar.com\n"
            "To: to <at> bar.com\n"
            "Subject: test\n")
    (newline)
    ;; mail body
    (insert "message\n"
            "Cc: >,@ <foo <at> bar.com>\n")) ;; by incorrect decode
  (gnus-registry-spool-action 1 "test"))

In stead of `message-fetch-field', calling `message-field-value' would
solve the problem since it ensures the buffer is narrowed at first.

diff -u "d:/msys64/mingw64/share/emacs/26.3/lisp/gnus/gnus-registry.el.orig" "d:/msys64/mingw64/share/emacs/26.3/lisp/gnus/gnus-registry.el"
--- d:/msys64/mingw64/share/emacs/26.3/lisp/gnus/gnus-registry.el.orig	2020-06-24 11:10:49.458397900 +0900
+++ d:/msys64/mingw64/share/emacs/26.3/lisp/gnus/gnus-registry.el	2020-06-23 11:08:23.170050000 +0900
@@ -405,10 +405,10 @@
   (let ((to (gnus-group-guess-full-name-from-command-method group))
           (recipients (or recipients
                           (gnus-registry-sort-addresses
-                           (or (message-fetch-field "cc") "")
-                           (or (message-fetch-field "to") ""))))
-          (subject (or subject (message-fetch-field "subject")))
-          (sender (or sender (message-fetch-field "from"))))
+                           (or (message-field-value "cc") "")
+                           (or (message-field-value "to") ""))))
+          (subject (or subject (message-field-value "subject")))
+          (sender (or sender (message-field-value "from"))))
       (when (and (stringp id) (string-match "\r$" id))
         (setq id (substring id 0 -1)))
       (gnus-message 7 "Gnus registry: article %s spooled to %s"

Diff finished.  Wed Jun 24 11:13:17 2020

Gnus v5.13
GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
 of 2020-04-04




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#42029; Package emacs,gnus. (Wed, 24 Jun 2020 17:26:02 GMT) Full text and rfc822 format available.

Message #8 received at 42029 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: tomotaka.suwa <at> gmail.com
Cc: 42029 <at> debbugs.gnu.org
Subject: Re: bug#42029: `gnus-registry-spool-action' gets field beyond
 message headers
Date: Wed, 24 Jun 2020 10:25:41 -0700
tomotaka.suwa <at> gmail.com writes:

> Hi,
>
> I've been suffering from `mail-source-crash-box' on getting new mail.
>
> After some debug and investigation, I noticed that
> `mail-extract-address-components' was failing by invalid addresses.
>
> The issue happened in `gnus-registry-spool-action' and invalid addresses
> are passed by calling `message-fetch-field' on the buffer not narrowed
> to message headers.
>
> Below snippet reproduce the root issue:
>
> (with-temp-buffer
>   (save-excursion
>     ;; mail header
>     (insert "From: from <at> bar.com\n"
>             "To: to <at> bar.com\n"
>             "Subject: test\n")
>     (newline)
>     ;; mail body
>     (insert "message\n"
>             "Cc: >,@ <foo <at> bar.com>\n")) ;; by incorrect decode
>   (gnus-registry-spool-action 1 "test"))
>
> In stead of `message-fetch-field', calling `message-field-value' would
> solve the problem since it ensures the buffer is narrowed at first.

Thanks for this report. It might be simpler to wrap the whole thing in a
single save-restriction+narrow-to-headers, since the function gets
called four times. What do you think?




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#42029; Package emacs,gnus. (Thu, 25 Jun 2020 02:00:01 GMT) Full text and rfc822 format available.

Message #11 received at 42029 <at> debbugs.gnu.org (full text, mbox):

From: Tomotaka SUWA <tomotaka.suwa <at> gmail.com>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 42029 <at> debbugs.gnu.org
Subject: Re: bug#42029: `gnus-registry-spool-action' gets field beyond message
 headers
Date: Thu, 25 Jun 2020 09:52:43 +0900
> Thanks for this report. It might be simpler to wrap the whole thing in a
> single save-restriction+narrow-to-headers, since the function gets
> called four times. What do you think?

I wrote the patch paying attention to minimize side effects since I'm not
familiar with that functionality. So if `gnus-registry-spool-action' is
interested in only mail headers, your proposal is much better.

-- 
Tomotaka SUWA




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#42029; Package emacs,gnus. (Fri, 26 Jun 2020 18:33:01 GMT) Full text and rfc822 format available.

Message #14 received at 42029 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Tomotaka SUWA <tomotaka.suwa <at> gmail.com>
Cc: 42029 <at> debbugs.gnu.org
Subject: Re: bug#42029: `gnus-registry-spool-action' gets field beyond
 message headers
Date: Fri, 26 Jun 2020 11:32:19 -0700
[Message part 1 (text/plain, inline)]
Tomotaka SUWA <tomotaka.suwa <at> gmail.com> writes:

>> Thanks for this report. It might be simpler to wrap the whole thing in a
>> single save-restriction+narrow-to-headers, since the function gets
>> called four times. What do you think?
>
> I wrote the patch paying attention to minimize side effects since I'm not
> familiar with that functionality. So if `gnus-registry-spool-action' is
> interested in only mail headers, your proposal is much better.

Okay! Would you be willing to give the attached diff a quick test?

Thanks,
Eric

[protect-registry-spool-action.diff (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#42029; Package emacs,gnus. (Fri, 26 Jun 2020 21:25:01 GMT) Full text and rfc822 format available.

Message #17 received at 42029 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: Tomotaka SUWA <tomotaka.suwa <at> gmail.com>, 42029 <at> debbugs.gnu.org
Subject: Re: bug#42029: `gnus-registry-spool-action' gets field beyond
 message headers
Date: Fri, 26 Jun 2020 22:24:30 +0100
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> +  (save-excursion
> +    (message-narrow-to-headers-or-head)

Shouldn't this additionally or instead be wrapped in save-restriction?

Thanks,

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#42029; Package emacs,gnus. (Fri, 26 Jun 2020 22:02:01 GMT) Full text and rfc822 format available.

Message #20 received at 42029 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Tomotaka SUWA <tomotaka.suwa <at> gmail.com>, 42029 <at> debbugs.gnu.org
Subject: Re: bug#42029: `gnus-registry-spool-action' gets field beyond
 message headers
Date: Fri, 26 Jun 2020 15:01:02 -0700
On 06/26/20 22:24 PM, Basil L. Contovounesios wrote:
> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>
>> +  (save-excursion
>> +    (message-narrow-to-headers-or-head)
>
> Shouldn't this additionally or instead be wrapped in save-restriction?

Bleagh, you're right, sorry about that. It was supposed to be
`save-restriction'.

Thanks!
Eric




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#42029; Package emacs,gnus. (Mon, 29 Jun 2020 02:28:01 GMT) Full text and rfc822 format available.

Message #23 received at 42029 <at> debbugs.gnu.org (full text, mbox):

From: Tomotaka SUWA <tomotaka.suwa <at> gmail.com>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 42029 <at> debbugs.gnu.org
Subject: Re: bug#42029: `gnus-registry-spool-action' gets field beyond message
 headers
Date: Mon, 29 Jun 2020 11:26:46 +0900
> Okay! Would you be willing to give the attached diff a quick test?

Sure. I gave a test with the `save-restriction' version and it
worked well.

By the way, does the change of `gnus-registry-get-article-marks'
have any relation to this issue?

Thanks,

-- 
Tomotaka SUWA




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#42029; Package emacs,gnus. (Sun, 19 Jul 2020 00:21:01 GMT) Full text and rfc822 format available.

Message #26 received at 42029 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Tomotaka SUWA <tomotaka.suwa <at> gmail.com>
Cc: Eric Abrahamsen <eric <at> ericabrahamsen.net>, 42029 <at> debbugs.gnu.org
Subject: Re: bug#42029: `gnus-registry-spool-action' gets field beyond
 message headers
Date: Sun, 19 Jul 2020 02:20:22 +0200
Tomotaka SUWA <tomotaka.suwa <at> gmail.com> writes:

>> Okay! Would you be willing to give the attached diff a quick test?
>
> Sure. I gave a test with the `save-restriction' version and it
> worked well.

Thanks for testing; I've now applied Eric's patch (with the additional
fix from Basil) to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 19 Jul 2020 00:21:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 42029 <at> debbugs.gnu.org and tomotaka.suwa <at> gmail.com Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 19 Jul 2020 00:21:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#42029; Package emacs,gnus. (Sun, 19 Jul 2020 03:06:01 GMT) Full text and rfc822 format available.

Message #33 received at 42029 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Tomotaka SUWA <tomotaka.suwa <at> gmail.com>, 42029 <at> debbugs.gnu.org
Subject: Re: bug#42029: `gnus-registry-spool-action' gets field beyond
 message headers
Date: Sat, 18 Jul 2020 20:05:35 -0700
On 07/19/20 02:20 AM, Lars Ingebrigtsen wrote:
> Tomotaka SUWA <tomotaka.suwa <at> gmail.com> writes:
>
>>> Okay! Would you be willing to give the attached diff a quick test?
>>
>> Sure. I gave a test with the `save-restriction' version and it
>> worked well.
>
> Thanks for testing; I've now applied Eric's patch (with the additional
> fix from Basil) to Emacs 28.

Thanks! I've had almost no time for coding recently...




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 16 Aug 2020 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 254 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.