GNU bug report logs - #64296
30.0.50; problem with gnus-summary-resend-message

Previous Next

Package: emacs;

Reported by: Peter Münster <pm <at> a16n.net>

Date: Mon, 26 Jun 2023 08:25:02 UTC

Severity: normal

Found in version 30.0.50

To reply to this bug, email your comments to 64296 AT debbugs.gnu.org.

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:
bug#64296; Package emacs. (Mon, 26 Jun 2023 08:25:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Peter Münster <pm <at> a16n.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 26 Jun 2023 08:25:02 GMT) Full text and rfc822 format available.

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

From: Peter Münster <pm <at> a16n.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; problem with gnus-summary-resend-message
Date: Mon, 26 Jun 2023 10:24:22 +0200
[Message part 1 (text/plain, inline)]
Hi,

When using "gnus-summary-resend-message" (keypress "SDr") on a message
with such a header: "To: undisclosed-recipients:;" , the function stops
with an error:

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("@" nil 0)
  split-string(nil "@")
  textsec-email-address-suspicious-p(nil)
  textsec-email-address-header-suspicious-p("undisclosed-recipients:;")
  textsec-suspicious-p("undisclosed-recipients:;" email-address-header)
  message-send-mail()
  message-resend("email <at> address.com")
  gnus-summary-resend-message("email <at> address.com" nil)
  funcall-interactively(gnus-summary-resend-message "email <at> address.com" nil)
  call-interactively(gnus-summary-resend-message nil nil)
  command-execute(gnus-summary-resend-message)
--8<---------------cut here---------------end--------------->8---

How could this be fixed please?

TIA for any help,
-- 
           Peter
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64296; Package emacs. (Tue, 27 Jun 2023 07:12:01 GMT) Full text and rfc822 format available.

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

From: Andrew Cohen <acohen <at> ust.hk>
To: Peter Münster <pm <at> a16n.net>
Cc: 64296 <at> debbugs.gnu.org
Subject: Re: bug#64296: 30.0.50; problem with gnus-summary-resend-message
Date: Tue, 27 Jun 2023 15:10:51 +0800
>>>>> "PM" == Peter Münster <pm <at> a16n.net> writes:

    PM> Hi, When using "gnus-summary-resend-message" (keypress "SDr") on
    PM> a message with such a header: "To: undisclosed-recipients:;" ,
    PM> the function stops with an error:

    PM> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
    PM> string-match("@" nil 0) split-string(nil "@")
    PM> textsec-email-address-suspicious-p(nil)
    PM> textsec-email-address-header-suspicious-p("undisclosed-recipients:;")
    PM> textsec-suspicious-p("undisclosed-recipients:;"
    PM> email-address-header) message-send-mail()
    PM> message-resend("email <at> address.com")
    PM> gnus-summary-resend-message("email <at> address.com" nil)
    PM> funcall-interactively(gnus-summary-resend-message
    PM> "email <at> address.com" nil)
    PM> call-interactively(gnus-summary-resend-message nil nil)
    PM> command-execute(gnus-summary-resend-message)

    PM> How could this be fixed please?

The problem is in the parsing of email headers. According to RFC5322 the
"To", "Cc", and "Bcc" headers may contain a comma-separated list of
addresses, where an address is either a mailbox or a group. A group is
an identifier followed by a list of mailboxes (this list is sandwiched
between a colon and a semi-colon). For example in your case the
identifier is "undisclosed-recipients" and the list of mailboxes is
empty.

It appears that this group syntax for these headers is simply not
implemented. I have tried a quick hack to get this working. Can you
replace `ietf-drums-parse-addresses' with the function definition below
and see if that works?  I have only done some very rudimentary testing
so it is possible that it fails to properly parse some existing headers.

#+begin_src emacs-lisp
(defun ietf-drums-parse-addresses (string &optional rawp)
  "Parse STRING and return a list of MAILBOX / DISPLAY-NAME pairs.
If RAWP, don't actually parse the addresses, but instead return
a list of address strings."
  (if (null string)
      nil
    (with-temp-buffer
      (ietf-drums-init string)
      (let ((beg (point))
	    pairs c address)
	(while (not (eobp))
	  (setq c (char-after))
	  (cond
           ((eq c '?:)
            (setq beg (1+ (point)))
            (skip-chars-forward "^;")
            (when-let ((address
                  (condition-case nil
                      (ietf-drums-parse-addresses
                       (buffer-substring beg (point)) rawp)
                    (error nil))))
              (if (listp address)
                  (setq pairs (append address pairs))
                (push address pairs)))
	    (forward-char 1)
	    (setq beg (point)))
	   ((memq c '(?\" ?< ?\())
	    (condition-case nil
		(forward-sexp 1)
	      (error
	       (skip-chars-forward "^,"))))
	   ((eq c ?,)
	    (setq address
		  (if rawp
		      (buffer-substring beg (point))
		    (condition-case nil
			(ietf-drums-parse-address
			 (buffer-substring beg (point)))
		      (error nil))))
	    (when (or (consp address) (and (stringp address) (< 0 (length address))))
              (push address pairs))
	    (forward-char 1)
	    (setq beg (point)))
	   (t
	    (forward-char 1))))
	(setq address
	      (if rawp
		  (buffer-substring beg (point))
		(condition-case nil
		    (ietf-drums-parse-address
		     (buffer-substring beg (point)))
		  (error nil))))
        (when (or (consp address) (and (stringp address) (< 0 (length address))))
          (push address pairs))
	(nreverse pairs)))))
#+end_src

-- 
Andrew Cohen




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64296; Package emacs. (Tue, 27 Jun 2023 08:16:02 GMT) Full text and rfc822 format available.

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

From: Peter Münster <pm <at> a16n.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#64296: 30.0.50; problem with gnus-summary-resend-message
Date: Tue, 27 Jun 2023 10:04:15 +0200
On Tue, Jun 27 2023, Andrew Cohen wrote:

> Can you replace `ietf-drums-parse-addresses' with the function
> definition below and see if that works?

Yes, it works. Thanks!

-- 
           Peter





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64296; Package emacs. (Tue, 27 Jun 2023 08:32:02 GMT) Full text and rfc822 format available.

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

From: Peter Münster <pm <at> a16n.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#64296: 30.0.50; problem with gnus-summary-resend-message
Date: Tue, 27 Jun 2023 10:31:16 +0200
On Tue, Jun 27 2023, Peter Münster wrote:

> Yes, it works. Thanks!

Sorry, no, there is a new problem. When displaying a message with such a
header:

--8<---------------cut here---------------start------------->8---
In-Reply-To: <87o7p2b7w5.fsf <at> a16n.net> ("Peter Münster"'s
 message of "Thu, 09
	Mar 2023 10:18:02 +0100")
--8<---------------cut here---------------end--------------->8---

I get this error: "cond: End of buffer"

And the message is displayed in it's raw format...

-- 
           Peter





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64296; Package emacs. (Tue, 27 Jun 2023 09:19:01 GMT) Full text and rfc822 format available.

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

From: Andrew Cohen <acohen <at> ust.hk>
To: Peter Münster <pm <at> a16n.net>
Cc: 64296 <at> debbugs.gnu.org
Subject: Re: bug#64296: 30.0.50; problem with gnus-summary-resend-message
Date: Tue, 27 Jun 2023 17:18:14 +0800
>>>>> "PM" == Peter Münster <pm <at> a16n.net> writes:

    PM> On Tue, Jun 27 2023, Peter Münster wrote:
    >> Yes, it works. Thanks!

    PM> Sorry, no, there is a new problem. When displaying a message
    PM> with such a header:

    PM> In-Reply-To: <87o7p2b7w5.fsf <at> a16n.net> ("Peter Münster"'s
    PM> message of "Thu, 09 Mar 2023 10:18:02 +0100")

    PM> I get this error: "cond: End of buffer"

    PM> And the message is displayed in it's raw format...

Hmm, OK. First can you confirm that using the original
ietf-drums-parse-addresses doesn't encounter this problem (I assume
thats the case, but best to be sure).

In the meantime I'll see if I can reproduce the problem to figure out
what is happening (if you can provide a backtrace that might also help).

Best,
Andy






-- 
Andrew Cohen
Director, HKUST Jockey Club Institute for Advanced Study
Lam Woo Foundation Professor and Chair Professor of Physics
The Hong Kong University of Science and Technology




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64296; Package emacs. (Tue, 27 Jun 2023 13:08:02 GMT) Full text and rfc822 format available.

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

From: Andrew Cohen <acohen <at> ust.hk>
To: Peter Münster <pm <at> a16n.net>
Cc: 64296 <at> debbugs.gnu.org
Subject: Re: bug#64296: 30.0.50; problem with gnus-summary-resend-message
Date: Tue, 27 Jun 2023 21:06:46 +0800
>>>>> "AC" == Andrew Cohen <acohen <at> ust.hk> writes:

>>>>> "PM" == Peter Münster <pm <at> a16n.net> writes:
    PM> On Tue, Jun 27 2023, Peter Münster wrote:
    >>> Yes, it works. Thanks!

    PM> Sorry, no, there is a new problem. When displaying a message
    PM> with such a header:

    PM> In-Reply-To: <87o7p2b7w5.fsf <at> a16n.net> ("Peter Münster"'s
    PM> message of "Thu, 09 Mar 2023 10:18:02 +0100")

    PM> I get this error: "cond: End of buffer"

    PM> And the message is displayed in it's raw format...

[...]

    AC> In the meantime I'll see if I can reproduce the problem to
    AC> figure out what is happening (if you can provide a backtrace
    AC> that might also help).

The problem is the presence of the ":" in the parenthetical comment
following the mailbox. If I am reading the spec correctly this is not
allowed (the ":" and ";" are special characters). But it is relatively
common nonetheless.

I think the following version should take care of it. Try it for awhile
and see if any other problems arise.  If not I'll push it to master.

#+begin_src emacs-lisp
(defun ietf-drums-parse-addresses (string &optional rawp)
  "Parse STRING and return a list of MAILBOX / DISPLAY-NAME pairs.
If RAWP, don't actually parse the addresses, but instead return
a list of address strings."
  (if (null string)
      nil
    (with-temp-buffer
      (ietf-drums-init string)
      (let ((beg (point))
	    pairs c address)
	(while (not (eobp))
	  (setq c (char-after))
	  (cond
           ((eq c '?:)
            (setq beg (1+ (point)))
            (skip-chars-forward "^;")
            (when-let ((address
                  (condition-case nil
                      (ietf-drums-parse-addresses
                       (buffer-substring beg (point)) rawp)
                    (error nil))))
              (if (listp address)
                  (setq pairs (append address pairs))
                (push address pairs)))
            (condition-case nil
	        (forward-char 1)
              (error nil))
	    (setq beg (point)))
	   ((memq c '(?\" ?< ?\())
	    (condition-case nil
		(forward-sexp 1)
	      (error
	       (skip-chars-forward "^,"))))
	   ((eq c ?,)
	    (setq address
		  (if rawp
		      (buffer-substring beg (point))
		    (condition-case nil
			(ietf-drums-parse-address
			 (buffer-substring beg (point)))
		      (error nil))))
	    (when (or (consp address)
                      (and (stringp address) (< 0 (length address))))
              (push address pairs))
	    (forward-char 1)
	    (setq beg (point)))
	   ((not (eobp))
	    (forward-char 1))))
	(setq address
	      (if rawp
		  (buffer-substring beg (point))
		(condition-case nil
		    (ietf-drums-parse-address
		     (buffer-substring beg (point)))
		  (error nil))))
        (when (or (consp address)
                  (and (stringp address) (< 0 (length address))))
          (push address pairs))
	(nreverse pairs)))))
#+end_src



-- 
Andrew Cohen




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64296; Package emacs. (Mon, 03 Jul 2023 08:45:02 GMT) Full text and rfc822 format available.

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

From: Peter Münster <pm <at> a16n.net>
To: Andrew Cohen <acohen <at> ust.hk>
Cc: 64296 <at> debbugs.gnu.org
Subject: Re: bug#64296: 30.0.50; problem with gnus-summary-resend-message
Date: Mon, 03 Jul 2023 10:44:43 +0200
[Message part 1 (text/plain, inline)]
On Tue, Jun 27 2023, Andrew Cohen wrote:

> I think the following version should take care of it. Try it for awhile
> and see if any other problems arise.  If not I'll push it to master.

Hi Andrew,

No other problems so far. It works for me very well!

Thanks,
-- 
           Peter
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 306 days ago.

Previous Next


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