From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Francesco =?UTF-8?Q?Potort=C3=AC?= Newsgroups: gmane.emacs.bugs Subject: bug#47616: 27.1; hardening mail-envelope-from Date: Wed, 07 Apr 2021 17:05:57 +0200 Organization: The GNU project Message-ID: <871rbm2kyy.fsf@tucano.isti.cnr.it> References: <87v98z60u4.fsf@tucano.isti.cnr.it> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26366"; mail-complaints-to="usenet@ciao.gmane.io" To: 47616@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 07 17:08:24 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lU9n4-0006kW-RS for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 07 Apr 2021 17:08:22 +0200 Original-Received: from localhost ([::1]:49520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lU9n3-0006I8-Kw for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 07 Apr 2021 11:08:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lU9lm-0005SP-3b for bug-gnu-emacs@gnu.org; Wed, 07 Apr 2021 11:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lU9ll-0000e6-Pc for bug-gnu-emacs@gnu.org; Wed, 07 Apr 2021 11:07:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lU9ll-0005Y9-KB for bug-gnu-emacs@gnu.org; Wed, 07 Apr 2021 11:07:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Francesco =?UTF-8?Q?Potort=C3=AC?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Apr 2021 15:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47616 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161780797121270 (code B ref -1); Wed, 07 Apr 2021 15:07:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Apr 2021 15:06:11 +0000 Original-Received: from localhost ([127.0.0.1]:45020 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lU9kw-0005Wz-OC for submit@debbugs.gnu.org; Wed, 07 Apr 2021 11:06:11 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:49670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lU9kv-0005Ws-Dr for submit@debbugs.gnu.org; Wed, 07 Apr 2021 11:06:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lU9kv-000538-0E for bug-gnu-emacs@gnu.org; Wed, 07 Apr 2021 11:06:09 -0400 Original-Received: from plesklin7.if1.ehiweb.it ([2a01:b600:1:61::1]:59195) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lU9kp-0008FZ-DP for bug-gnu-emacs@gnu.org; Wed, 07 Apr 2021 11:06:05 -0400 Original-Received: from tucano.isti.cnr.it (tucano.isti.cnr.it [146.48.81.102]) by plesklin7.if1.ehiweb.it (Postfix) with ESMTPSA id 08112100794 for ; Wed, 7 Apr 2021 17:05:58 +0200 (CEST) In-Reply-To: <87v98z60u4.fsf@tucano.isti.cnr.it> (pot@gnu.org) X-fingerprint: 4B02 6187 5C03 D6B1 2E31 7666 09DF 2DC9 BE21 6115 X-PPP-Message-ID: <20210407150558.6363.37929@plesklin7.if1.ehiweb.it> X-PPP-Vhost: potorti.it Received-SPF: softfail client-ip=2a01:b600:1:61::1; envelope-from=pot@gnu.org; helo=plesklin7.if1.ehiweb.it X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:203690 Archived-At: >(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))