Subject: Re: bug#42029: `gnus-registry-spool-action' gets field beyond message headers

From: Eric Abrahamsen <[email-masked]>
Date: Wed, 24 Jun 2020 10:25:41 -0700

[email-masked] 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: [email-masked]\n"
>             "To: [email-masked]\n"
>             "Subject: test\n")
>     (newline)
>     ;; mail body
>     (insert "message\n"
>             "Cc: >,@ <[email-masked]>\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?