[Top][All Lists]

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

[elpa] externals/debbugs d0d2ce3 266/311: Correctly parse non-ascii name

From: Stefan Monnier
Subject: [elpa] externals/debbugs d0d2ce3 266/311: Correctly parse non-ascii names in debbugs-gnu
Date: Sun, 29 Nov 2020 18:42:26 -0500 (EST)

branch: externals/debbugs
commit d0d2ce3e6bcb83e29410dd9845bb07c0e6071bcf
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Correctly parse non-ascii names in debbugs-gnu
    * packages/debbugs/debbugs-gnu.el (debbugs-gnu--split-address): New 
    (debbugs-gnu-show-reports): Use it to correctly get the names,
    since the originator/owner fields aren't valid mail headers, but
    are just "octets <octects>".
    (debbugs-gnu-sort-submitter): Ditto.
    (debbugs-gnu-sort-title): Ditto.
 debbugs-gnu.el | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index 9639a0c..82dd582 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -707,6 +707,16 @@ marked as \"client-side filter\"."
      ;; Otherwise, we retrieve the bugs from the server.
      (t (apply #'debbugs-get-bugs args)))))
+(defun debbugs-gnu--split-address (string)
+  "Split mail-like STRING into a name/email address pair."
+  (if (string-match "\\`\\(.*\\) <\\([^>]+\\)>\\'" string)
+      (let ((name (match-string 1 string))
+           (email (match-string 2 string)))
+       ;; Remove leading/trailing quote chars.
+       (cons email
+             (replace-regexp-in-string "\\`\"\\|\"\\'" "" name)))
+    (cons string string)))
 (defun debbugs-gnu-show-reports (&optional offline)
   "Show bug reports.
 If OFFLINE is non-nil, the query is not sent to the server.  Bugs
@@ -743,11 +753,11 @@ are taken from the cache instead."
             (words (cons (cdr (assq 'severity status))
                          (cdr (assq 'keywords status))))
             (address (if (cdr (assq 'originator status))
-                         (mail-header-parse-address
+                         (debbugs-gnu--split-address
                           (decode-coding-string (cdr (assq 'originator status))
             (owner (if (cdr (assq 'owner status))
-                       (car (mail-header-parse-address
+                       (car (debbugs-gnu--split-address
                              (decode-coding-string (cdr (assq 'owner status))
             (subject (if (cdr (assq 'subject status))
@@ -1104,11 +1114,11 @@ Used instead of `tabulated-list-print-entry'."
 (defun debbugs-gnu-sort-submitter (s1 s2)
   (let ((address1
-        (mail-header-parse-address
+        (debbugs-gnu--split-address
           (or (cdr (assq 'originator (car s1))) "") 'utf-8)))
-        (mail-header-parse-address
+        (debbugs-gnu--split-address
           (or (cdr (assq 'originator (car s2))) "") 'utf-8))))
@@ -1131,13 +1141,13 @@ Used instead of `tabulated-list-print-entry'."
 (defun debbugs-gnu-sort-title (s1 s2)
   (let ((owner1
-        (car (mail-header-parse-address
+        (car (debbugs-gnu--split-address
                (or (cdr (assq 'owner (car s1))) "") 'utf-8))))
         (decode-coding-string (or (cdr (assq 'subject (car s1))) "") 'utf-8))
-        (car (mail-header-parse-address
+        (car (debbugs-gnu--split-address
                (or (cdr (assq 'owner (car s2))) "") 'utf-8))))

reply via email to

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