GNU bug report logs - #47616
27.1; hardening mail-envelope-from

Previous Next

Package: emacs;

Reported by: Francesco Potortì <pot <at> gnu.org>

Date: Tue, 6 Apr 2021 12:43:02 UTC

Severity: normal

Tags: fixed

Found in version 27.1

Fixed in version 28.1

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Francesco Potortì <pot <at> gnu.org>
To: 47616 <at> debbugs.gnu.org
Subject: bug#47616: 27.1; hardening mail-envelope-from
Date: Wed, 07 Apr 2021 17:05:57 +0200
>(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))




This bug report was last modified 4 years and 10 days ago.

Previous Next


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