VM

"Display using External Viewer" produces corrupt file under emacs 23

Bug #495089 reported by Richard Sharman
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
VM
Fix Released
Low
Uday Reddy

Bug Description

The "Display using External Viewer" menu option isn't working under
Emacs-23. The file produced is corrupted and typically is slightly
smaller than it should be. This is with vm 7.19. With emacs 22.1
this problem doesn't happen.

The "Save to File" does work, however.

I found that by removing the call to set-buffer-multibyte in
vm-mime-display-external-generic the problem went away.

% diff -c vm-mime.el.orig vm-mime.el
*** vm-mime.el.orig Tue Dec 1 11:07:31 2009
--- vm-mime.el Thu Dec 10 10:12:31 2009
***************
*** 1967,1973 ****
         (vm-mime-transfer-decode-region layout
             (point-min)
             (point-max))
! (set-buffer-multibyte t)
         (set-buffer target)
         (setq start (point))
         (insert-buffer-substring work-buffer)
--- 1967,1973 ----
         (vm-mime-transfer-decode-region layout
             (point-min)
             (point-max))
! ;; (set-buffer-multibyte t)
         (set-buffer target)
         (setq start (point))
         (insert-buffer-substring work-buffer)
%

Examples of using the "Save to File"
-rw------- 1 sharman gx5000 3310 Dec 10 10:13 test.gif
-rw------- 1 sharman gx5000 3424 Dec 10 10:13 test.jpeg
sharmanpc 19%

whearas when using "Display using External Viewer" the temporary file
was a different size
-rw------- 1 sharman gx5000 3302 Dec 10 10:12 test.gif
-rw------- 1 sharman gx5000 3420 Dec 10 10:12 test.jpeg

Tags: emacs23
Revision history for this message
Richard Sharman (richard-sharman) wrote :
Uday Reddy (reddyuday)
tags: added: mime
Uday Reddy (reddyuday)
Changed in vm:
assignee: nobody → Uday Reddy (reddyuday)
status: New → Confirmed
importance: Undecided → High
tags: added: emacs23
tags: removed: mime
Revision history for this message
Uday Reddy (reddyuday) wrote :

Richard, thanks for reporting this. I believe the problem exists with the current version of VM as well. So this report is valuable. However, the specific line that you identified as the cause isn't in the current version. So, we will have to hunt it down. There are a few other occurrences of set-buffer-multibyte in vm-mime.el. We will have to check all of them, I suppose.

The test.jpg file that you attached is presumably the image that was attached in the message?

Cheers,
Uday

Revision history for this message
Uday Reddy (reddyuday) wrote :

I did a fix for the vm-mime.el in version 7.19 in order to understand what is going on here. Please find the file attached. The current devo version is working fine. (Rob must have done it some time.)

Cheers,
Uday

Changed in vm:
status: Confirmed → In Progress
importance: High → Low
Revision history for this message
Uday Reddy (reddyuday) wrote :

The problem here was caused by the call to set-buffer-multibyte, which is a questionable function. There are 13 remaining calls to this function in the current version. I will keep this bug report alive until I have looked at all the 13.

Revision history for this message
Richard Sharman (richard-sharman) wrote : [Bug 495089] Re: "Display using External Viewer" produces corrupt file under emacs 23

Uday Reddy writes:
| Richard, thanks for reporting this. I believe the problem exists with
| the current version of VM as well. So this report is valuable.
| However, the specific line that you identified as the cause isn't in the
| current version.
| So, we will have to hunt it down. There are a few
| other occurrences of set-buffer-multibyte in vm-mime.el. We will have
| to check all of them, I suppose.
|
| The test.jpg file that you attached is presumably the image that was
| attached in the message?
|

Yes. It happened to me on several real [and much larger] files so I
thought I'd try a simple file as a test case - and sure enough it did
fail - and so I attached it in case it was useful. (I was using
electric-eye to display the image and found that a corrupt .png file was
displayed but looked bizarre whearas a bad .gif file typically could not
be displayed at all.)

I looked at the output produced and it started off right then some bytes
were swapped e.g. c0 98 would become 98 c0 and the length would be
wrong; usually shorter I think. The buffer seemed to be correct
before the call to set-buffer-multibyte but incorrect after it so I
removed the line and it worked for me but I was really poking in the
dark!

Richard

Revision history for this message
Richard Sharman (richard-sharman) wrote :

Uday Reddy writes:
| I did a fix for the vm-mime.el in version 7.19 in order to understand
| what is going on here. Please find the file attached. The current devo
| version is working fine. (Rob must have done it some time.)
|
| Cheers,
| Uday
|

This works well for me. I tried it on several mail messages and all
worked fine.

Richard

Revision history for this message
Uday Reddy (reddyuday) wrote :

I am going to close this bug report and open a new one for set-buffer-multibyte checks.

Changed in vm:
status: In Progress → Fix Released
milestone: none → 8.1.0-beta
Uday Reddy (reddyuday)
Changed in vm:
milestone: 8.1.0b → 8.1.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.