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

Full log


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




This bug report was last modified 1 year and 354 days ago.

Previous Next


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