unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrew Cohen <acohen@ust.hk>
To: "Peter Münster" <pm@a16n.net>
Cc: 64296@debbugs.gnu.org
Subject: bug#64296: 30.0.50; problem with gnus-summary-resend-message
Date: Tue, 27 Jun 2023 21:06:46 +0800	[thread overview]
Message-ID: <87mt0lqck9.fsf@ust.hk> (raw)
In-Reply-To: <87o7l1s1pl.fsf@ust.hk> (Andrew Cohen's message of "Tue, 27 Jun 2023 17:18:14 +0800")

>>>>> "AC" == Andrew Cohen <acohen@ust.hk> writes:

>>>>> "PM" == Peter Münster <pm@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@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





  reply	other threads:[~2023-06-27 13:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26  8:24 bug#64296: 30.0.50; problem with gnus-summary-resend-message Peter Münster
2023-06-27  7:10 ` Andrew Cohen
2023-06-27  8:04   ` Peter Münster
2023-06-27  8:31     ` Peter Münster
2023-06-27  9:18       ` Andrew Cohen
2023-06-27 13:06         ` Andrew Cohen [this message]
2023-07-03  8:44           ` Peter Münster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mt0lqck9.fsf@ust.hk \
    --to=acohen@ust.hk \
    --cc=64296@debbugs.gnu.org \
    --cc=pm@a16n.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).