all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Antoine Beaupre <anarcat@debian.org>
Cc: 32639@debbugs.gnu.org
Subject: bug#32639: 25.2; message-mode.el: invalid email address gives strange results
Date: Mon, 13 May 2019 16:53:27 -0400	[thread overview]
Message-ID: <87ftpiqdo8.fsf@mouse.gnus.org> (raw)
In-Reply-To: <87sh2ok6jv.fsf@curie.anarc.at> (Antoine Beaupre's message of "Tue, 04 Sep 2018 22:43:32 -0400")

Antoine Beaupre <anarcat@debian.org> writes:

> Emacs' message mode is not very indulgent on invalid email addresses and
> especially typo which can occur in copy-paste.
>
> For example, I tried to send an email today to "foo <bar@example.com>"
> only I screwed up when pasting so my "To:" header was actually:
>
>     To: foo bar <quux@example.com
>
> ie. without a trailing bracket. Emacs happily accepts this (arguably)
> invalid email address and expands that to "foo@$fqdn" and "bar
> <quux@example.com". The former will fail because $fqdn is obviously not
> the right domain and the latter will fail because "bar <quux" is not a
> valid user at "example.com".

Yeah, Message should refuse to try to send email with invalid To/Cc
addresses, I think.

> I've probed a little into how this could be fixed, but somewhat got lost
> between message.el's `message-fix-before-sending' and
> `mail-extract-address-components'. Presumably there's some part in there
> that could be improved, but I am not sure regular expressions are up to
> standard to parse email addresses, as those are notoriously complicated.

The standards-compliant function to use is:

(mail-header-parse-addresses "foo bar <quux@example.com")
=> nil

(mail-header-parse-addresses "foo bar <quux@example.com>")
=> (("quux@example.com" . "foo bar"))

The problem is that this function doesn't really tell the user anything
about what's wrong with the address -- it's either able to parse it or
not.

Another twist here is that if you have at least one valid address in the
list, it won't tell you that there's anything wrong:

(mail-header-parse-addresses "foo bar <quux@example.com>, zot>")
=> (("quux@example.com" . "foo bar"))

But I guess we could add a parameter to ietf-drums-parse-addresses to
make it return a more complete result.

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





  reply	other threads:[~2019-05-13 20:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05  2:43 bug#32639: 25.2; message-mode.el: invalid email address gives strange results Antoine Beaupre
2019-05-13 20:53 ` Lars Ingebrigtsen [this message]
2019-09-22 23:06   ` Lars Ingebrigtsen

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

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

  git send-email \
    --in-reply-to=87ftpiqdo8.fsf@mouse.gnus.org \
    --to=larsi@gnus.org \
    --cc=32639@debbugs.gnu.org \
    --cc=anarcat@debian.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.