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.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Glenn Morris <rgm <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#9978: closed (23.3; Rmail's rmail-output fails when
 destination mailbox is empty and visited [PATCH])
Date: Tue, 15 Nov 2011 00:41:03 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 14 Nov 2011 19:39:44 -0500
with message-id <254ny66wxb.fsf <at> fencepost.gnu.org>
and subject line Re: bug#9978: 23.3; Rmail's rmail-output fails when destination mailbox is empty and visited [PATCH]
has caused the debbugs.gnu.org bug report #9978,
regarding 23.3; Rmail's rmail-output fails when destination mailbox is empty and visited [PATCH]
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
9978: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9978
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
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)


[Message part 3 (message/rfc822, inline)]
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.


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.