emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e37b96432b8: Fix parsing of mail address headers (bug#64296)


From: Andrew G Cohen
Subject: master e37b96432b8: Fix parsing of mail address headers (bug#64296)
Date: Tue, 4 Jul 2023 21:05:48 -0400 (EDT)

branch: master
commit e37b96432b89521871e947f322545f154547dd1b
Author: Andrew G Cohen <cohen@andy.bu.edu>
Commit: Andrew G Cohen <cohen@andy.bu.edu>

    Fix parsing of mail address headers (bug#64296)
    
    RFC5322 specifies that an address header may be a list of both
    individual mailboxes and mailbox groups.  This patch introduces
    support for parsing headers that include groups.
    
    * lisp/mail/ietf-drums.el (ietf-drums-parse-addresses): Allow message
    address headers to include both mailboxes and groups.
---
 lisp/mail/ietf-drums.el | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/lisp/mail/ietf-drums.el b/lisp/mail/ietf-drums.el
index f60a3a3da28..aa714292bcc 100644
--- a/lisp/mail/ietf-drums.el
+++ b/lisp/mail/ietf-drums.el
@@ -272,6 +272,21 @@ a list of address strings."
        (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)
@@ -285,10 +300,12 @@ a list of address strings."
                        (ietf-drums-parse-address
                         (buffer-substring beg (point)))
                      (error nil))))
-           (if address (push address pairs))
+           (when (or (consp address)
+                      (and (stringp address) (< 0 (length address))))
+              (push address pairs))
            (forward-char 1)
            (setq beg (point)))
-          (t
+          ((not (eobp))
            (forward-char 1))))
        (setq address
              (if rawp
@@ -297,7 +314,9 @@ a list of address strings."
                    (ietf-drums-parse-address
                     (buffer-substring beg (point)))
                  (error nil))))
-       (if address (push address pairs))
+        (when (or (consp address)
+                  (and (stringp address) (< 0 (length address))))
+          (push address pairs))
        (nreverse pairs)))))
 
 (defun ietf-drums-unfold-fws ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]