From unknown Tue Jun 17 03:39:14 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#7760 <7760@debbugs.gnu.org> To: bug#7760 <7760@debbugs.gnu.org> Subject: Status: mail-mbox-from produces invalid mbox From lines when From lines are multiline Reply-To: bug#7760 <7760@debbugs.gnu.org> Date: Tue, 17 Jun 2025 10:39:14 +0000 retitle 7760 mail-mbox-from produces invalid mbox From lines when From line= s are multiline reassign 7760 emacs submitter 7760 mark.lillibridge@hp.com severity 7760 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 29 22:00:16 2010 Received: (at submit) by debbugs.gnu.org; 30 Dec 2010 03:00:17 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PY8kR-0002Ca-Qq for submit@debbugs.gnu.org; Wed, 29 Dec 2010 22:00:16 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PY8kP-0002CO-O4 for submit@debbugs.gnu.org; Wed, 29 Dec 2010 22:00:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PY8r5-0004c9-1B for submit@debbugs.gnu.org; Wed, 29 Dec 2010 22:07:08 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:50382) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PY8r4-0004c4-UY for submit@debbugs.gnu.org; Wed, 29 Dec 2010 22:07:06 -0500 Received: from [140.186.70.92] (port=34151 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PY8r3-0005gj-7t for bug-gnu-emacs@gnu.org; Wed, 29 Dec 2010 22:07:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PY8r1-0004bQ-Aw for bug-gnu-emacs@gnu.org; Wed, 29 Dec 2010 22:07:05 -0500 Received: from gundega.hpl.hp.com ([192.6.19.190]:51095) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PY8r1-0004at-2k for bug-gnu-emacs@gnu.org; Wed, 29 Dec 2010 22:07:03 -0500 Received: from mailhub-pa1.hpl.hp.com (mailhub-pa1.hpl.hp.com [15.25.115.25]) by gundega.hpl.hp.com (8.14.3/8.14.3/HPL-PA Relay) with ESMTP id oBU36wH8001795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 29 Dec 2010 19:06:58 -0800 Received: from ts-rhel5 (ts-rhel5.hpl.hp.com [15.25.118.27]) by mailhub-pa1.hpl.hp.com (8.14.3/8.14.3/HPL-PA Hub) with ESMTP id oBU36uwo023852; Wed, 29 Dec 2010 19:06:56 -0800 Date: Wed, 29 Dec 2010 19:06:56 -0800 Message-Id: From: Mark Lillibridge To: bug-gnu-emacs@gnu.org Subject: mail-mbox-from produces invalid mbox From lines when From lines are multiline X-Scanned-By: MIMEDefang 2.69 on 15.0.48.190 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -5.5 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: mark.lillibridge@hp.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.5 (-----) [at least version 23.1 onwards] Mbox from lines are required to be a single line starting with "From "; see mail/rmail.el:720 for evidence of this: (defvar rmail-unix-mail-delimiter (let ((time-zone-regexp (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?" "\\|[-+]?[0-9][0-9][0-9][0-9]" "\\|" "\\) *"))) (concat "From " ;; Many things can happen to an RFC 822 mailbox before it is put into ;; a `From' line. The leading phrase can be stripped, e.g. ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g. ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF ;; can be removed, e.g. ;; From: joe@y.z (Joe K ;; User) ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and ;; From: Joe User ;; ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'. ;; The mailbox can be removed or be replaced by white space, e.g. ;; From: "Joe User"{space}{tab} ;; ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996', ;; where {space} and {tab} represent the Ascii space and tab characters. ;; We want to match the results of any of these manglings. ;; The following regexp rejects names whose first characters are ;; obviously bogus, but after that anything goes. "\\([^\0-\b\n-\r\^?].*\\)? " ;; The time the message was sent. "\\([^\0-\r \^?]+\\) +" ; day of the week "\\([^\0-\r \^?]+\\) +" ; month "\\([0-3]?[0-9]\\) +" ; day of month "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day ;; Perhaps a time zone, specified by an abbreviation, or by a ;; numeric offset. time-zone-regexp ;; The year. " \\([0-9][0-9]+\\) *" ;; On some systems the time zone can appear after the year, too. time-zone-regexp ;; Old uucp cruft. "\\(remote from .*\\)?" "\n")) "Regexp matching the delimiter of messages in UNIX mail format \(UNIX From lines), minus the initial ^. Note that if you change this expression, you must change the code in `rmail-nuke-pinhead-header' that knows the exact ordering of the \\( \\) subexpressions.") However, mail-mbox-from in mail/mail-utils.el:387: (defun mail-mbox-from () "Return an mbox \"From \" line for the current message. The buffer should be narrowed to just the header." (let ((from (or (mail-fetch-field "from") (mail-fetch-field "really-from") (mail-fetch-field "sender") "unknown")) (date (mail-fetch-field "date"))) (format "From %s %s\n" (mail-strip-quoted-names from) (or (and date (ignore-errors (current-time-string (date-to-time date)))) (current-time-string))))) produces multiple line results for messages containing multiple line >From lines; for example, consider the following message headers from a real message: Return-Path: Resent-Date: Fri, 25 Oct 1996 18:01:41 -0500 (EST) Resent-To: objecttypes-redistribution@daimi.aau.dk Date: Fri, 25 Oct 1996 18:36:19 -0400 From: Andrew Myers , Joseph Bank , Barbara Liskov To: objecttypes@daimi.aau.dk Subject: Parameterized Types for Java (This message may or may not meet various e-mail standards; that is irrelevant -- mail-mbox-from must give valid results for all real messages.) On this message, mail-mbox-from produces the following invalid result: "From andru@lcs.mit.edu, jbank@martigny.ai.mit.edu, liskov@lcs.mit.edu Fri Oct 25 15:36:19 1996 " I attach a fairly simple fix which ignores everything starting with a comma or newline in the from/etc. lines. It instead produces: "From CloveApple@aol.com Thu Dec 1 23:37:29 1994 " Truncating starting with a newline is justified by the comments above: ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF ;; can be removed, e.g. ;; From: joe@y.z (Joe K ;; User) ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and ;; From: Joe User ;; ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'. Truncating starting with a comma is to attempt to preserve the spirit of the from line (give a single sending mailbox), but is not strictly necessary. - Mark New version is: (defun mail-mbox-from () "Return an mbox \"From \" line for the current message. The buffer should be narrowed to just the header." (let* ((from (or (mail-fetch-field "from") (mail-fetch-field "really-from") (mail-fetch-field "sender") "unknown")) (stripped-from (mail-strip-quoted-names from)) (final-from (substring stripped-from 0 (string-match "[,\n]" stripped-from))) (date (mail-fetch-field "date"))) (format "From %s %s\n" final-from (or (and date (ignore-errors (current-time-string (date-to-time date)))) (current-time-string))))) ts-rhel5 [158]% diff new-mail-utils.el new-mail-utils2.el 390,395c390,398 < (let ((from (or (mail-fetch-field "from") < (mail-fetch-field "really-from") < (mail-fetch-field "sender") < "unknown")) < (date (mail-fetch-field "date"))) < (format "From %s %s\n" (mail-strip-quoted-names from) --- > (let* ((from (or (mail-fetch-field "from") > (mail-fetch-field "really-from") > (mail-fetch-field "sender") > "unknown")) > (stripped-from (mail-strip-quoted-names from)) > (final-from (substring stripped-from 0 > (string-match "[,\n]" stripped-from))) > (date (mail-fetch-field "date"))) > (format "From %s %s\n" final-from From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 01 21:29:06 2011 Received: (at 7760-done) by debbugs.gnu.org; 2 Jan 2011 02:29:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PZDgw-000516-2y for submit@debbugs.gnu.org; Sat, 01 Jan 2011 21:29:06 -0500 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PZDgu-00050e-M3 for 7760-done@debbugs.gnu.org; Sat, 01 Jan 2011 21:29:05 -0500 Received: from localhost ([127.0.0.1]:34031) by fencepost.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PZDnf-0006wL-VN; Sat, 01 Jan 2011 21:36:04 -0500 To: 7760-done@debbugs.gnu.org Subject: Re: bug#7760: mail-mbox-from produces invalid mbox From lines when From lines are multiline References: From: Glenn Morris X-Spook: STARLAN assassination [Hello to all my friends and fans X-Ran: !5lQ*~s**Brf)Xl<-cn<$FQAN)sLw@DS.KMu$Ik1M\)?/f;%RE7PWob]:QDCO&E2Yvr,@m X-Hue: magenta X-Debbugs-No-Ack: yes X-Attribution: GM Date: Sat, 01 Jan 2011 21:36:03 -0500 In-Reply-To: (Mark Lillibridge's message of "Wed\, 29 Dec 2010 19\:06\:56 -0800") Message-ID: <8qvd28jalo.fsf@fencepost.gnu.org> User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -4.7 (----) X-Debbugs-Envelope-To: 7760-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.7 (----) Version: 23.3 Thanks; I applied something similar. From unknown Tue Jun 17 03:39:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 30 Jan 2011 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator