From: "Francesco Potortì" <pot@gnu.org>
To: 47616@debbugs.gnu.org
Subject: bug#47616: 27.1; hardening mail-envelope-from
Date: Wed, 07 Apr 2021 17:05:57 +0200 [thread overview]
Message-ID: <871rbm2kyy.fsf@tucano.isti.cnr.it> (raw)
In-Reply-To: <87v98z60u4.fsf@tucano.isti.cnr.it> (pot@gnu.org)
>(defun mail-envelope-from ()
> "Return the envelope mail address to use when sending mail.
>This function uses `mail-envelope-from'."
> (or (if (eq mail-envelope-from 'header)
> (nth 1 (mail-extract-address-components
> (save-restriction
> (save-excursion
> (goto-char (point-max))
> (re-search-backward
> (concat "^" (regexp-quote mail-header-separator) "\n")
> nil t)
> (narrow-to-region (point-min) (point))
> (mail-fetch-field "From")))))
> mail-envelope-from)
> user-mail-address))
This one is better (I had forgotten about mail-header-end)
(require 'sendmail)
(defun mail-envelope-from ()
"Return the envelope mail address to use when sending mail.
This function uses `mail-envelope-from'."
(or (if (eq mail-envelope-from 'header)
(let ((from-field (save-restriction
(narrow-to-region (point-min) (mail-header-end))
(mail-fetch-field "From"))))
(when from-field
(nth 1 (mail-extract-address-components from-field))))
mail-envelope-from)
user-mail-address))
next prev parent reply other threads:[~2021-04-07 15:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 12:42 bug#47616: 27.1; hardening mail-envelope-from Francesco Potortì
2021-04-07 15:05 ` Francesco Potortì [this message]
2021-05-06 10:22 ` Lars Ingebrigtsen
2021-05-06 12:16 ` Francesco Potortì
2021-05-07 11:17 ` Lars Ingebrigtsen
2021-05-07 11:33 ` Eli Zaretskii
2021-05-07 12:09 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871rbm2kyy.fsf@tucano.isti.cnr.it \
--to=pot@gnu.org \
--cc=47616@debbugs.gnu.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).