unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13209: 23.3; RMAIL rmail-edit-current-message damages MIME messages
@ 2012-12-17 15:46 Dale R. Worley
  2012-12-17 17:03 ` Glenn Morris
  0 siblings, 1 reply; 2+ messages in thread
From: Dale R. Worley @ 2012-12-17 15:46 UTC (permalink / raw)
  To: 13209

-----

Summary:

In RMAIL, if a message is a MIME message that is not just a
text/plain, executing rmail-edit-current-message (`e') on the message
destroys its contents, even if no changes are made before exiting
(with `C-c C-c').  A simple change to block rmail-edit-current-message
on MIME messages is proposed.

Emacs version:

GNU Emacs 23.3.1 (i686-redhat-linux-gnu, GTK+ Version 2.24.8) of 2012-11-17 on buildvm-19.phx2.fedoraproject.org
This is current for "Fedora release 16 (Verne)".

How to reproduce:

Create a mail file containing a MIME multipart message.  Open the file
with RMAIL and select the message.  The resulting display is something
like this:

    Date: Mon, 17 Dec 2012 09:47:08 -0500
    From: Dale Worley <worley@c-66-31-108-177.hsd1.ma.comcast.net>
    To: worley@freeze.ariadne.com
    Subject: Test 1

    [1:text/plain Hide]
    Test 1
    [2:image/jpeg Show Save:airplant.jpeg (282kB)]

Edit the message by typing `e', moving the cursor to after "Test 1",
then adding some text.  The resulting display is:

    Date: Mon, 17 Dec 2012 09:47:08 -0500
    From: Dale Worley <worley@c-66-31-108-177.hsd1.ma.comcast.net>
    To: worley@freeze.ariadne.com
    Subject: Test 1

    [1:text/plain Hide]
    Test 1
    More text.
    [2:image/jpeg Show Save:airplant.jpeg (282kB)]

Type `C-c C-c' to exit rmail-edit mode.

Save the file with `C-x C-s'.

Now open the mail file literally and find the message that you edited.
What you will see is that the message's body is now what was
*displayed* for it during the editing session.  For example:

    From worley@c-66-31-108-177.hsd1.ma.comcast.net  Mon Dec 17 09:47:08 2012
    Return-Path: <worley@c-66-31-108-177.hsd1.ma.comcast.net>
    Received: from freeze.ariadne.com (freeze.ariadne.com [127.0.0.1])
	    by freeze.ariadne.com (8.14.5/8.14.5) with ESMTP id qBHEl8OO007938
	    for <worley@freeze.ariadne.com>; Mon, 17 Dec 2012 09:47:08 -0500
    Received: (from worley@localhost)
	    by freeze.ariadne.com (8.14.5/8.14.5/Submit) id qBHEl8Tp007937;
	    Mon, 17 Dec 2012 09:47:08 -0500
    Date: Mon, 17 Dec 2012 09:47:08 -0500
    Message-Id: <201212171447.qBHEl8Tp007937@freeze.ariadne.com>
    From: Dale Worley <worley@c-66-31-108-177.hsd1.ma.comcast.net>
    To: worley@freeze.ariadne.com
    Subject: Test 1
    Content-type: text/plain; charset=us-ascii
    Mime-Version: 1.0
    Content-Type: multipart/mixed; boundary="----------make-mime-1355755615-7926"
    X-Attachments: airplant.jpeg;
    X-RMAIL-ATTRIBUTES: --E-----

    [1:text/plain Hide]
    Test 1
    More text.
    [2:image/jpeg Show Save:airplant.jpeg (282kB)]

In this case, the image/jpeg component is irreversably lost.

Proposed partial fix:

The following change prevents rmail-edit from being invoked on a
message if it is a MIME message, except when the entire body is
text/plain:

    (defun rmail-edit-current-message ()
      "Edit the contents of this message."
      (interactive)
      (if (zerop rmail-total-messages)
          (error "No messages in this buffer"))
+     ;; If the message is MIME, only edit it if the whole body is text/plain.
+     ;; (This depends on the particular return value of (rmail-mime-message-p).)
+     (let ((mm (rmail-mime-message-p)))
+       (if (and mm
+                (not (string-equal (car (rmail-mime-entity-type mm))
+                                   "text/plain")))
+           (error "Non-text MIME messages cannot be edited")))
      (rmail-modify-format)
      ...

This change also blocks invocation of rmail-edit from the
rmail-summary buffer under the same circumstances.

This change is deficient in that it depends on the return value of
rmail-mime-message-p, which is only specified as nil vs. non-nil.
(There may be a better function to call for this information than
rmail-mime-message-p.)

A better change would allow the user to edit MIME messages when they
are displayed in "raw" mode (as a consequence of the `v' command).

A much better change would allow the user to edit text components of
MIME messaegs, preserving the non-text components.

-----


In GNU Emacs 23.3.1 (i686-redhat-linux-gnu, GTK+ Version 2.24.8)
 of 2012-11-17 on buildvm-19.phx2.fedoraproject.org
Windowing system distributor `Fedora Project', version 11.0.11104000
configured using `configure  '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xft' '--with-xpm' '--with-x-toolkit=gtk' 'build_alias=i686-redhat-linux-gnu' 'host_alias=i686-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -m32 -march=i686 -mtune=a
 tom -fasynchronous-unwind-tables' 'LDFLAGS=-Wl,-z,relro ''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Fundamental

Minor modes in effect:
  shell-dirtrack-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
a n g e SPC w o u l d SPC a l l o w SPC t h e SPC u 
s e r SPC t o SPC e d i t SPC t e x t SPC c o m p o 
n e n t s SPC o f SPC M I M E SPC m e s s a e g s , 
SPC p r e s e r v i c <backspace> n g SPC t C-a C-o 
C-o A SPC b e t t e r SPC c h a n g e SPC w o u l d 
SPC a l l o w SPC t h e SPC u s e r SPC t o SPC e d 
i t SPC M I M E S-SPC m e s s a g e s SPC a s SPC l 
o n <M-backspace> <M-backspace> w h e n SPC t h e y 
SPC w e <M-backspace> a r e SPC d i s p l a y e d SPC 
i n SPC " r a w " SPC m o d e SPC ( a s SPC a SPC c 
o n s e q u e n c e SPC o f SPC t h e SPC ` v ' SPC 
c o m m a n d ) . M-q C-n C-n M-q C-n h e SPC n o n 
- t e x t SPC c o m p o n e n t s . <return> <return> 
<backspace> M-< M-> C-x s <switch-frame> C-x b * i 
<tab> <return> SPC <backspace> M-< C-s b u g C-a C-n 
<switch-frame> C-x 5 2 <switch-frame> M-x r e p o r 
t - e m a <tab> <return>

Recent messages:
Replaced 4 occurrences
Mark set [2 times]
Auto-saving...done
Mark set
Auto-saving...done
Mark set [2 times]
(No files need saving)
Auto-saving...
Mark set
Mark saved where search started

Load-path shadows:
/home/worley/emacs/rmail-spam-filter hides /usr/share/emacs/23.3/lisp/mail/rmail-spam-filter

Features:
(shadow emacsbug tabify noutline outline easy-mmode edmacro kmacro
debug help-fns rmailedit rmailout help-mode view jka-compr info
mule-util dired-aux dired rmailsum cookie1 ispell newcomment rmailmm
cl cl-19 mailalias message sendmail ecomplete rfc822 mml easymenu
mml-sec password-cache mm-decode mm-bodies mm-encode mailcap
mailabbrev nnheader gnus-util netrc gmm-utils wid-edit mailheader
canlock sha1 hex-util hashcash mail-parse rfc2231 rmail rfc2047
rfc2045 ietf-drums time-date qp mm-util mail-prsvr mail-utils
multi-isearch shell comint ring cc-styles cc-align cc-engine cc-vars
cc-defs regexp-opt tooltip ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode
register page menu-bar rfn-eshadow timer select scroll-bar mldrag
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
loaddefs button minibuffer faces cus-face files text-properties
overlay md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
system-font-setting font-render-setting gtk x-toolkit x multi-tty
emacs)





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-17 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-17 15:46 bug#13209: 23.3; RMAIL rmail-edit-current-message damages MIME messages Dale R. Worley
2012-12-17 17:03 ` Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).