GNU bug report logs - #56422
29.0.50; mail-extract-address-components poorly handles " via " addresses

Previous Next

Package: emacs;

Reported by: sds <at> gnu.org

Date: Wed, 6 Jul 2022 15:23:01 UTC

Severity: normal

Found in version 29.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 56422 in the body.
You can then email your comments to 56422 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#56422; Package emacs. (Wed, 06 Jul 2022 15:23:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to sds <at> gnu.org:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 06 Jul 2022 15:23:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sam Steingold <sds <at> gnu.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; mail-extract-address-components poorly handles " via "
 addresses
Date: Wed, 06 Jul 2022 11:22:35 -0400
Often "From" email addresses in mailing lists look like this:

--8<---------------cut here---------------start------------->8---
From: Po Lu via "Emacs development discussions." <emacs-devel <at> gnu.org>
From: carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs <at> gnu.org>
From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs <at> gnu.org>
--8<---------------cut here---------------end--------------->8---

`mail-extract-address-components' handles them poorly:

--8<---------------cut here---------------start------------->8---
(mail-extract-address-components "Po Lu via \"Emacs development discussions.\" <emacs-devel <at> gnu.org>")
=> ("Po Lu via" "emacs-devel <at> gnu.org")
(mail-extract-address-components "carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs <at> gnu.org>")
=> ("carlmarcos" "help-gnu-emacs <at> gnu.org")
(mail-extract-address-components "Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs <at> gnu.org>")
=> ("Stefan Monnier via Users list for the" "help-gnu-emacs <at> gnu.org")
--8<---------------cut here---------------end--------------->8---

The correct handling would be

--8<---------------cut here---------------start------------->8---
(mail-extract-address-components "Po Lu via \"Emacs development discussions.\" <emacs-devel <at> gnu.org>")
=> ("Emacs development discussions." "emacs-devel <at> gnu.org")
(mail-extract-address-components "carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs <at> gnu.org>")
=> ("Users list for the GNU Emacs text editor" "help-gnu-emacs <at> gnu.org")
(mail-extract-address-components "Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs <at> gnu.org>")
=> ("Users list for the GNU Emacs text editor" "help-gnu-emacs <at> gnu.org")
--8<---------------cut here---------------end--------------->8---

or, at least,

--8<---------------cut here---------------start------------->8---
(mail-extract-address-components "Po Lu via \"Emacs development discussions.\" <emacs-devel <at> gnu.org>")
=> ("Po Lu via \"Emacs development discussions.\"" "emacs-devel <at> gnu.org")
(mail-extract-address-components "carlmarcos--- via Users list for the GNU Emacs text editor <help-gnu-emacs <at> gnu.org>")
=> ("carlmarcos--- via Users list for the GNU Emacs text editor" "help-gnu-emacs <at> gnu.org")
(mail-extract-address-components "Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs <at> gnu.org>")
=> ("Stefan Monnier via Users list for the GNU Emacs text editor" "help-gnu-emacs <at> gnu.org")
--8<---------------cut here---------------end--------------->8---

Please see the relevant discussion on the BBDB user list:
https://lists.nongnu.org/archive/html/bbdb-user/2022-06/msg00000.html
https://lists.nongnu.org/archive/html/bbdb-user/2022-07/msg00000.html

In https://lists.nongnu.org/archive/html/bbdb-user/2022-07/msg00006.html
I propose a workaround for a _single_ address (i.e., when the second
argument to `mail-extract-address-components' is nil):
--8<---------------cut here---------------start------------->8---
(defun mail-extract-handle-via (args)
  "Handle `via` in email address"
  (let ((address (car args))
        (all (cadr args)))
    (if (and (null all)
             (string-match " via \\(.*\\)$" address))
        (list (match-string 1 address) nil)
      (list address all))))
(advice-add 'mail-extract-address-components :filter-args 'mail-extract-handle-via)
--8<---------------cut here---------------end--------------->8---

this is clearly suboptimal, especially when the "name" part of the
address contains many words:

--8<---------------cut here---------------start------------->8---
(mail-extract-address-components "Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs <at> gnu.org>")
("Users list for the" "help-gnu-emacs <at> gnu.org")
--8<---------------cut here---------------end--------------->8---

It appears that `mail-header-parse-address' is a better choice (as per
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=10406) but you might still
consider addressing this issue...

Thank you.

In GNU Emacs 29.0.50 (build 2, x86_64-apple-darwin21.5.0, NS appkit-2113.50 Version 12.4 (Build 21F79))
 of 2022-07-05 built on 3c22fb11fdab.ant.amazon.com
Repository revision: 59276ff81d1ab391f4e3cd91f3070a12c51a3507
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.4

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
https://www.peaceandtolerance.org/ https://honestreporting.com
The past is gone, the present is ephemeral, the future is a guess.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#56422; Package emacs. (Thu, 07 Jul 2022 09:11:01 GMT) Full text and rfc822 format available.

Message #8 received at 56422 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Sam Steingold <sds <at> gnu.org>
Cc: 56422 <at> debbugs.gnu.org
Subject: Re: bug#56422: 29.0.50; mail-extract-address-components poorly
 handles " via " addresses
Date: Thu, 07 Jul 2022 11:10:28 +0200
Sam Steingold <sds <at> gnu.org> writes:

> The correct handling would be
>
> (mail-extract-address-components "Po Lu via \"Emacs development discussions.\" <emacs-devel <at> gnu.org>")
> => ("Emacs development discussions." "emacs-devel <at> gnu.org")

mail-extract-address-components is a DWIM-ish thing that doesn't have
much documented behaviour -- it just tries to make things "pretty" by
applying lots of (mostly misguided) heuristics.  So talking about
"correct" here isn't er correct.

If you have an RFC822bis From header, you should use
`mail-header-parse-address'.  If you have something that's vaguely like
a mail header and want to split it, use `mail-header-parse-address-lax'.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#56422; Package emacs. (Mon, 11 Jul 2022 10:56:01 GMT) Full text and rfc822 format available.

Message #11 received at 56422 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Sam Steingold <sds <at> gnu.org>
Cc: 56422 <at> debbugs.gnu.org
Subject: Re: bug#56422: 29.0.50; mail-extract-address-components poorly
 handles " via " addresses
Date: Mon, 11 Jul 2022 12:55:25 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> If you have an RFC822bis From header, you should use
> `mail-header-parse-address'.  If you have something that's vaguely like
> a mail header and want to split it, use `mail-header-parse-address-lax'.

So I don't think there's anything to fix here, and I'm closing this bug
report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 56422 <at> debbugs.gnu.org and sds <at> gnu.org Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 11 Jul 2022 10:56:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 08 Aug 2022 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 312 days ago.

Previous Next


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