Re: Handling "via" addresses
Sam Steingold <[email protected]> Wed, 06 Jul 2022 13:45:58 -0400
| Newsgroups | gmane.emacs.bbdb.user |
|---|---|
| Message-ID | <[email protected]> |
--=-=-= Content-Type: text/plain > * Roland Winkler <[email protected]> [2022-07-05 18:47:27 -0500]: > > On Tue, Jul 05 2022, Sam Steingold wrote: >> Roland, are you going to deal with this somehow or should I report this >> as an Emacs bug? > > The function bbdb-extract-address-components passes the return value of > mail-extract-address-components through bbdb-clean-address-components > that calls the user-defined functions bbdb-message-clean-name-function > and bbdb-message-clean-mail-function. But it seems to me that these > user functions should be needed only for very exotic cases. So yes, it > seems to me that mail-extract-address-components is really the most > appropriate place to deal with your issue. (It's my point of view that > BBDB should not try to reinvent the wheel if it deals with problems that > are not BBDB-specific which, I believe, is the case here.) Therefore, > I suggest to file a bug report for mail-extract-address-components. Actually, `mail-extract-address-components' is the wrong function to use here. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Use-mail-header-parse-address-instead-of-mail-extrac.patch Content-Description: Use `mail-header-parse-address' instead of `mail-extract-address-components'. From feff548533797f5060c6fd7e40e987e2693c396a Mon Sep 17 00:00:00 2001 From: Sam Steingold <[email protected]> Date: Wed, 6 Jul 2022 13:42:41 -0400 Subject: [PATCH] Use `mail-header-parse-address' instead of `mail-extract-address-components'. `mail-extract-address-components' mis-handles many From headers, see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=10406 and https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56422 * lisp/bbdb.el (bbdb-clean-address-components): Expect a cons cell from `mail-header-parse-address' rather than a list from `mail-extract-address-components'. (bbdb-extract-address-components): Use `mail-header-parse-address' instead of `mail-extract-address-components'. --- ChangeLog | 11 +++++++++++ lisp/bbdb.el | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d43db3..22713cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2022-07-06 Sam Steingold <[email protected]> + Use `mail-header-parse-address' instead of `mail-extract-address-components'. + `mail-extract-address-components' mis-handles many From headers, + see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=10406 + and https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56422 + * lisp/bbdb.el (bbdb-clean-address-components): Expect + a cons cell from `mail-header-parse-address' rather than + a list from `mail-extract-address-components'. + (bbdb-extract-address-components): Use `mail-header-parse-address' + instead of `mail-extract-address-components'. + 2022-07-05 Arash Esbati <[email protected]> Silence the compiler. * lisp/bbdb.el, lisp/bbdb-com.el: Fix unescaped single quotes in diff --git a/lisp/bbdb.el b/lisp/bbdb.el index e18c54b..d53651d 100644 --- a/lisp/bbdb.el +++ b/lisp/bbdb.el @@ -1119,7 +1119,7 @@ and `bbdb-message-ignore-mail-re'." (defcustom bbdb-message-clean-name-function #'bbdb-message-clean-name-default "Function to clean up the name in the header of a message. It takes one argument, the name as extracted by -`mail-extract-address-components'. +`mail-header-parse-address'. If this function returns nil, BBDB assumes that there is no name." :group 'bbdb-mua :type 'function) @@ -2222,12 +2222,12 @@ Used with return values of `bbdb-add-job'." (defun bbdb-clean-address-components (components) "Clean mail address COMPONENTS. -COMPONENTS is a list (NAME MAIL) as returned -by `mail-extract-address-components'. +COMPONENTS is a cons (MAIL . NAME) as returned +by `mail-header-parse-address'. Pass NAME through `bbdb-message-clean-name-function' and MAIL through `bbdb-message-clean-mail-function'." - (let ((name (car components)) - (mail (cadr components))) + (let ((name (cdr components)) + (mail (car components))) (if (and name bbdb-message-clean-name-function) (setq name (funcall bbdb-message-clean-name-function name))) (if (and name bbdb-message-ignore-name-re @@ -2244,13 +2244,15 @@ and MAIL through `bbdb-message-clean-mail-function'." (defun bbdb-extract-address-components (address &optional all) "Given an RFC-822 address ADDRESS, extract full name and canonical address. -This function behaves like `mail-extract-address-components', but it passes +This function behaves like `mail-header-parse-address', but it passes its return value through `bbdb-clean-address-components'. See also `bbdb-decompose-bbdb-address'." + ;; the name of this function is a holdover from the times when it used + ;; `mail-extract-address-components' instead of `mail-header-parse-address' (if all (mapcar #'bbdb-clean-address-components - (mail-extract-address-components address t)) - (bbdb-clean-address-components (mail-extract-address-components address)))) + (mail-header-parse-addresses address)) + (bbdb-clean-address-components (mail-header-parse-address address)))) ;; Inspired by `gnus-extract-address-components' from gnus-utils. (defun bbdb-decompose-bbdb-address (mail) -- 2.24.3 (Apple Git-128) --=-=-= Content-Type: text/plain -- Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113 http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com https://www.memritv.org http://think-israel.org https://camera.org If You Want Breakfast In Bed, Sleep In the Kitchen. --=-=-=--