From unknown Fri Sep 05 11:52:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9978: 23.3; Rmail's rmail-output fails when destination mailbox is empty and visited [PATCH] Resent-From: Mark Lillibridge Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Nov 2011 22:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 9978 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 9978@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Reply-To: mark.lillibridge@hp.com Received: via spool by submit@debbugs.gnu.org id=B.13206197255604 (code B ref -1); Sun, 06 Nov 2011 22:49:01 +0000 Received: (at submit) by debbugs.gnu.org; 6 Nov 2011 22:48:45 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RNBW8-0001SL-Tp for submit@debbugs.gnu.org; Sun, 06 Nov 2011 17:48:45 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RNBW6-0001SD-72 for submit@debbugs.gnu.org; Sun, 06 Nov 2011 17:48:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RNBTN-0004RA-4h for submit@debbugs.gnu.org; Sun, 06 Nov 2011 17:45:53 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:60572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNBTN-0004R6-3H for submit@debbugs.gnu.org; Sun, 06 Nov 2011 17:45:53 -0500 Received: from eggs.gnu.org ([140.186.70.92]:60984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNBTM-0005rW-7W for bug-gnu-emacs@gnu.org; Sun, 06 Nov 2011 17:45:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RNBTL-0004Qu-5J for bug-gnu-emacs@gnu.org; Sun, 06 Nov 2011 17:45:52 -0500 Received: from gundega.hpl.hp.com ([192.6.19.190]:33534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNBTK-0004Qq-SP for bug-gnu-emacs@gnu.org; Sun, 06 Nov 2011 17:45:51 -0500 Received: from mailhub-pa1.hpl.hp.com (mailhub-pa1.hpl.hp.com [15.25.115.25]) by gundega.hpl.hp.com (8.14.4/8.14.4/HPL-PA Relay) with ESMTP id pA6Mjk99032635 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sun, 6 Nov 2011 14:45:47 -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 pA6MjirE023459; Sun, 6 Nov 2011 14:45:45 -0800 From: Mark Lillibridge Date: Sun, 06 Nov 2011 14:45:44 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Scanned-By: MIMEDefang 2.71 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, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.5 (-----) 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: -5.6 (-----) Reproducing: Visit a new Rmail file (e.g., using 'i') then output a message to that new file from another ('o'). Return to that file's buffer and save it ('s'). Notice the "invalid mbox file" error message... This bug is caused by the following code in the function rmail-output-to-rmail-buffer: rmailout.el:379: ;; Make sure the last old message ends with a blank line. (goto-char (point-max)) (rmail-ensure-blank-line) This code is attempting to ensure that the current rmail-buffer is in valid mbox format; in particular, that it ends with a blank line. However, empty mbox files do *not* end with a blank line so this code corrupts the mailbox when empty by adding an extra newline: (defun rmail-ensure-blank-line () "Ensure a message ends in a blank line. Call with point at the end of the message." (unless (bolp) (insert "\n")) (unless (looking-back "\n\n") (insert "\n"))) The result is that the outputted message is preceded by a blank line, which is not valid mbox format. The fix is simple and similar to that of bug number 9974: (goto-char (point-max)) ;; Make sure current Rmail buffer is in valid mbox format (end ;; with a blank line unless no messages): ;; (fixes damage caused by bug #9974) (unless (bobp) (while (not (looking-back "\n\n")) (insert "\n"))) A patch follows. - Mark ts-rhel5 [260]% ( setenv LC_ALL C ; setenv TZ UTC0 ; diff -Naur original-rmailout.el rmailout.el ) --- original-rmailout.el 2011-11-06 22:14:56.353674000 +0000 +++ rmailout.el 2011-11-06 22:23:30.723302000 +0000 @@ -376,9 +376,13 @@ (rmail-maybe-set-message-counters) ;; Insert the new message after the last old message. (widen) - ;; Make sure the last old message ends with a blank line. (goto-char (point-max)) - (rmail-ensure-blank-line) + ;; Make sure current Rmail buffer is in valid mbox format (end + ;; with a blank line unless no messages): + ;; (fixes damage caused by bug #9974) + (unless (bobp) + (while (not (looking-back "\n\n")) + (insert "\n"))) ;; Insert the new message at the end. (narrow-to-region (point-max) (point-max)) (insert-buffer-substring tembuf) From unknown Fri Sep 05 11:52:31 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: mark.lillibridge@hp.com Subject: bug#9978: closed (Re: bug#9978: 23.3; Rmail's rmail-output fails when destination mailbox is empty and visited [PATCH]) Message-ID: References: <254ny66wxb.fsf@fencepost.gnu.org> X-Gnu-PR-Message: they-closed 9978 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 9978@debbugs.gnu.org Date: Tue, 15 Nov 2011 00:41:05 +0000 Content-Type: multipart/mixed; boundary="----------=_1321317665-7622-1" This is a multi-part message in MIME format... ------------=_1321317665-7622-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #9978: 23.3; Rmail's rmail-output fails when destination mailbox is empty a= nd visited [PATCH] which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 9978@debbugs.gnu.org. --=20 9978: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D9978 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1321317665-7622-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 9978-done) by debbugs.gnu.org; 15 Nov 2011 00:40:24 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RQ74Z-0001y1-LW for submit@debbugs.gnu.org; Mon, 14 Nov 2011 19:40:24 -0500 Received: from fencepost.gnu.org ([140.186.70.10] ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RQ74X-0001xu-OL for 9978-done@debbugs.gnu.org; Mon, 14 Nov 2011 19:40:22 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1RQ73w-0004ec-Vn; Mon, 14 Nov 2011 19:39:45 -0500 From: Glenn Morris To: 9978-done@debbugs.gnu.org Subject: Re: bug#9978: 23.3; Rmail's rmail-output fails when destination mailbox is empty and visited [PATCH] References: X-Spook: Israel Uzbekistan BCCI encryption asset Bruxelles SAPO X-Ran: n:^sjT17xJKY)7'.a?*~Bg(b(nMXJ:vHnxymLoSV_.mbViE(x-y1PzT^vAR|"Xx[`fc#w9 X-Hue: cyan X-Debbugs-No-Ack: yes X-Attribution: GM Date: Mon, 14 Nov 2011 19:39:44 -0500 In-Reply-To: (Mark Lillibridge's message of "Sun, 06 Nov 2011 14:45:44 -0800") Message-ID: <254ny66wxb.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: -6.4 (------) X-Debbugs-Envelope-To: 9978-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: -6.4 (------) Version: 24.0.92 Thanks; fixed. ------------=_1321317665-7622-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 6 Nov 2011 22:48:45 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RNBW8-0001SL-Tp for submit@debbugs.gnu.org; Sun, 06 Nov 2011 17:48:45 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RNBW6-0001SD-72 for submit@debbugs.gnu.org; Sun, 06 Nov 2011 17:48:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RNBTN-0004RA-4h for submit@debbugs.gnu.org; Sun, 06 Nov 2011 17:45:53 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:60572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNBTN-0004R6-3H for submit@debbugs.gnu.org; Sun, 06 Nov 2011 17:45:53 -0500 Received: from eggs.gnu.org ([140.186.70.92]:60984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNBTM-0005rW-7W for bug-gnu-emacs@gnu.org; Sun, 06 Nov 2011 17:45:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RNBTL-0004Qu-5J for bug-gnu-emacs@gnu.org; Sun, 06 Nov 2011 17:45:52 -0500 Received: from gundega.hpl.hp.com ([192.6.19.190]:33534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNBTK-0004Qq-SP for bug-gnu-emacs@gnu.org; Sun, 06 Nov 2011 17:45:51 -0500 Received: from mailhub-pa1.hpl.hp.com (mailhub-pa1.hpl.hp.com [15.25.115.25]) by gundega.hpl.hp.com (8.14.4/8.14.4/HPL-PA Relay) with ESMTP id pA6Mjk99032635 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sun, 6 Nov 2011 14:45:47 -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 pA6MjirE023459; Sun, 6 Nov 2011 14:45:45 -0800 From: Mark Lillibridge To: bug-gnu-emacs@gnu.org Subject: 23.3; Rmail's rmail-output fails when destination mailbox is empty and visited [PATCH] Date: Sun, 06 Nov 2011 14:45:44 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Scanned-By: MIMEDefang 2.71 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, 3) X-Received-From: 140.186.70.17 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.6 (-----) Reproducing: Visit a new Rmail file (e.g., using 'i') then output a message to that new file from another ('o'). Return to that file's buffer and save it ('s'). Notice the "invalid mbox file" error message... This bug is caused by the following code in the function rmail-output-to-rmail-buffer: rmailout.el:379: ;; Make sure the last old message ends with a blank line. (goto-char (point-max)) (rmail-ensure-blank-line) This code is attempting to ensure that the current rmail-buffer is in valid mbox format; in particular, that it ends with a blank line. However, empty mbox files do *not* end with a blank line so this code corrupts the mailbox when empty by adding an extra newline: (defun rmail-ensure-blank-line () "Ensure a message ends in a blank line. Call with point at the end of the message." (unless (bolp) (insert "\n")) (unless (looking-back "\n\n") (insert "\n"))) The result is that the outputted message is preceded by a blank line, which is not valid mbox format. The fix is simple and similar to that of bug number 9974: (goto-char (point-max)) ;; Make sure current Rmail buffer is in valid mbox format (end ;; with a blank line unless no messages): ;; (fixes damage caused by bug #9974) (unless (bobp) (while (not (looking-back "\n\n")) (insert "\n"))) A patch follows. - Mark ts-rhel5 [260]% ( setenv LC_ALL C ; setenv TZ UTC0 ; diff -Naur original-rmailout.el rmailout.el ) --- original-rmailout.el 2011-11-06 22:14:56.353674000 +0000 +++ rmailout.el 2011-11-06 22:23:30.723302000 +0000 @@ -376,9 +376,13 @@ (rmail-maybe-set-message-counters) ;; Insert the new message after the last old message. (widen) - ;; Make sure the last old message ends with a blank line. (goto-char (point-max)) - (rmail-ensure-blank-line) + ;; Make sure current Rmail buffer is in valid mbox format (end + ;; with a blank line unless no messages): + ;; (fixes damage caused by bug #9974) + (unless (bobp) + (while (not (looking-back "\n\n")) + (insert "\n"))) ;; Insert the new message at the end. (narrow-to-region (point-max) (point-max)) (insert-buffer-substring tembuf) ------------=_1321317665-7622-1--