GNU bug report logs - #9978
23.3; Rmail's rmail-output fails when destination mailbox is empty and visited [PATCH]

Previous Next

Package: emacs;

Reported by: mark.lillibridge <at> hp.com

Date: Sun, 6 Nov 2011 22:49:01 UTC

Severity: normal

Tags: patch

Found in version 23.3

Fixed in version 24.0.92

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9978 in the body.
You can then email your comments to 9978 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#9978; Package emacs. (Sun, 06 Nov 2011 22:49:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to mark.lillibridge <at> hp.com:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 06 Nov 2011 22:49:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mark Lillibridge <mark.lillibridge <at> hp.com>
To: bug-gnu-emacs <at> 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
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)




Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Tue, 15 Nov 2011 00:41:03 GMT) Full text and rfc822 format available.

Notification sent to mark.lillibridge <at> hp.com:
bug acknowledged by developer. (Tue, 15 Nov 2011 00:41:05 GMT) Full text and rfc822 format available.

Message #10 received at 9978-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 9978-done <at> debbugs.gnu.org
Subject: Re: bug#9978: 23.3;
	Rmail's rmail-output fails when destination mailbox is empty and
	visited [PATCH]
Date: Mon, 14 Nov 2011 19:39:44 -0500
Version: 24.0.92

Thanks; fixed.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 13 Dec 2011 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 252 days ago.

Previous Next


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