Gnus development mailing list
 help / color / mirror / Atom feed
* MIME decoding broken on Win NT
@ 1998-11-23 20:51 Matt Armstrong
  1998-11-23 21:03 ` Shenghuo ZHU
  1998-11-24  8:50 ` Shenghuo ZHU
  0 siblings, 2 replies; 7+ messages in thread
From: Matt Armstrong @ 1998-11-23 20:51 UTC (permalink / raw)


MIME decoding is broken again under Win NT (it got fixed somewhere
around 0.35, but broken somewhere since then).  Under Win NT,
default-buffer-file-coding-system is undecided-dos, not
undecided-unix.  There are places in the MIME handling within pgnus
where the default buffer-file-coding-system is used, so cr/lf
translation happens on binary stuff.

I sent myself a binary attachment consisting of two bytes: "\r\n".
Getting that to decode correctly (with the standard "1 b" key
sequence) involved this patch:


*** mm-decode.el.orig   Mon Nov 23 11:52:04 1998
--- mm-decode.el        Mon Nov 23 12:22:18 1998
***************
*** 447,453 ****
        (when (or (not (file-exists-p file))
                (yes-or-no-p (format "File %s already exists; overwrite? "
                                     file)))
!       (write-region (point-min) (point-max) file)))))

  (defun mm-pipe-part (handle)
    "Pipe HANDLE to a process."
--- 447,458 ----
        (when (or (not (file-exists-p file))
                (yes-or-no-p (format "File %s already exists; overwrite? "
                                     file)))
!       (let ((coding-system-for-write
!              (if (equal "text" (car (split-string
!                                      (car (mm-handle-type handle)) "/")))
!                  'buffer-file-coding-system
!                'binary)))
!         (write-region (point-min) (point-max) file))))))

  (defun mm-pipe-part (handle)


But I still can't decode the picture of RMS in Lars' "MIME Test One"
e-mail, so some holes still exist.

I think a better fix would be a more systematic approach -- pouring
through the MIME stuff and making sure non "text/*" parts never get
processed in a buffer where default-buffer-file-coding-system is in
effect.

I'm using NT Emacs 20.3.1, base64.el, and no mailcap stuff.

-- 
matta




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

* Re: MIME decoding broken on Win NT
  1998-11-23 20:51 MIME decoding broken on Win NT Matt Armstrong
@ 1998-11-23 21:03 ` Shenghuo ZHU
  1998-11-24 10:15   ` Lars Magne Ingebrigtsen
  1998-11-24  8:50 ` Shenghuo ZHU
  1 sibling, 1 reply; 7+ messages in thread
From: Shenghuo ZHU @ 1998-11-23 21:03 UTC (permalink / raw)


>>>>> "MA" == Matt Armstrong <matta@geoworks.com> writes:
MA> !       (let ((coding-system-for-write
MA> !              (if (equal "text" (car (split-string
MA> !                                      (car (mm-handle-type handle)) "/")))
MA> !                  'buffer-file-coding-system
                       ^ Should this single quote be deleted?
MA> !                'binary)))
MA> !         (write-region (point-min) (point-max) file))))))

-- 
Shenghuo


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

* Re: MIME decoding broken on Win NT
  1998-11-23 20:51 MIME decoding broken on Win NT Matt Armstrong
  1998-11-23 21:03 ` Shenghuo ZHU
@ 1998-11-24  8:50 ` Shenghuo ZHU
  1998-11-24 19:13   ` Matt Armstrong
  1 sibling, 1 reply; 7+ messages in thread
From: Shenghuo ZHU @ 1998-11-24  8:50 UTC (permalink / raw)


>>>>> "Matt" == Matt Armstrong <matta@geoworks.com> writes:

Matt> MIME decoding is broken again under Win NT (it got fixed somewhere
Matt> around 0.35, but broken somewhere since then).  Under Win NT,
Matt> default-buffer-file-coding-system is undecided-dos, not
Matt> undecided-unix.  There are places in the MIME handling within pgnus
Matt> where the default buffer-file-coding-system is used, so cr/lf
Matt> translation happens on binary stuff.

Matt> I sent myself a binary attachment consisting of two bytes: "\r\n".
Matt> Getting that to decode correctly (with the standard "1 b" key
Matt> sequence) involved this patch:


Matt> *** mm-decode.el.orig   Mon Nov 23 11:52:04 1998
Matt> --- mm-decode.el        Mon Nov 23 12:22:18 1998
Matt> ***************
Matt> *** 447,453 ****
Matt>         (when (or (not (file-exists-p file))
Matt>                 (yes-or-no-p (format "File %s already exists; overwrite? "
Matt>                                      file)))
Matt> !       (write-region (point-min) (point-max) file)))))

Matt>   (defun mm-pipe-part (handle)
Matt>     "Pipe HANDLE to a process."
Matt> --- 447,458 ----
Matt>         (when (or (not (file-exists-p file))
Matt>                 (yes-or-no-p (format "File %s already exists; overwrite? "
Matt>                                      file)))
Matt> !       (let ((coding-system-for-write
Matt> !              (if (equal "text" (car (split-string
Matt> !                                      (car (mm-handle-type handle)) "/")))
Matt> !                  'buffer-file-coding-system
Matt> !                'binary)))
Matt> !         (write-region (point-min) (point-max) file))))))

Matt>   (defun mm-pipe-part (handle)

These codes are in (mm-with-unibyte-buffer ...), in which
buffer-file-coding-system is supposed to be binary. But in
mm-with-unibyte-buffer, buffer-file-coding-system is set to nil, which
is not equivalent to binary, though it works good in Unix.
mm-with-binary-buffer seems to be a better name than
mm-with-unibyte-buffer.

Other modifications are replacing no-conversion with binary, since
`no-conversion' is defined differently in GNU Emacs and XEmacs.

NT Emacs user, please test the patch to save and view images.

-- 
Shenghuo

:- cut ---------------------------------------------------------
--- ChangeLog	1998/11/24 07:57:08	1.3
+++ ChangeLog	1998/11/24 08:25:07
@@ -1,3 +1,11 @@
+Tue Nov 24 03:01:48 1998  Shenghuo ZHU  <zsh@cs.rochester.edu>
+
+	* mm-decode.el (mm-display-external): Use binary instead of
+	no-conversion.
+	* gnus-agent.el (gnus-agent-file-coding-system): Ditto.
+	* nnheader.el (nnheader-file-coding-system): Ditto.
+	* mm-util.el (mm-with-unibyte-buffer): Use binary instead of nil.
+
 Mon Nov 23 01:51:57 1998  Shenghuo ZHU  <zsh@cs.rochester.edu>
 
 	* gnus-sum.el (gnus-newsgroup-setup-default-charset): Use group

--- mm-util.el	1998/11/23 05:51:21	1.1
+++ mm-util.el	1998/11/24 07:58:43
@@ -220,7 +220,7 @@
 		     (get-buffer-create (generate-new-buffer-name " *temp*")))
 	       (unwind-protect
 		   (with-current-buffer ,temp-buffer
-		     (let (buffer-file-coding-system)
+		     (let ((buffer-file-coding-system 'binary))
 		       ,@forms))
 		 (and (buffer-name ,temp-buffer)
 		      (kill-buffer ,temp-buffer))))

--- nnheader.el	1998/11/23 05:51:23	1.1
+++ nnheader.el	1998/11/24 08:24:35
@@ -754,7 +754,7 @@
       (when (string-match (car ange-ftp-path-format) path)
 	(ange-ftp-re-read-dir path)))))
 
-(defvar nnheader-file-coding-system 'no-conversion
+(defvar nnheader-file-coding-system 'binary
   "Coding system used in file backends of Gnus.")
 
 (defun nnheader-insert-file-contents (filename &optional visit beg end replace)

--- mm-decode.el	1998/11/23 05:51:21	1.1
+++ mm-decode.el	1998/11/24 08:07:30
@@ -237,7 +237,7 @@
 		(select-window win)))
 	    (switch-to-buffer (generate-new-buffer "*mm*")))
 	  (buffer-disable-undo)
-	  (mm-set-buffer-file-coding-system 'no-conversion)
+	  (mm-set-buffer-file-coding-system 'binary)
 	  (insert-buffer-substring cur)
 	  (message "Viewing with %s" method)
 	  (let ((mm (current-buffer)))
@@ -261,7 +261,7 @@
 					 dir))
 	  (setq file (make-temp-name (expand-file-name "mm." dir))))
 	(write-region (point-min) (point-max)
-		      file nil 'nomesg nil 'no-conversion)
+		      file nil 'nomesg nil 'binary)
 	(message "Viewing with %s" method)
 	(unwind-protect
 	    (setq process

--- gnus-agent.el	1998/11/23 05:51:10	1.1
+++ gnus-agent.el	1998/11/24 08:26:21
@@ -92,7 +92,7 @@
 (defvar gnus-agent-spam-hashtb nil)
 (defvar gnus-agent-file-name nil)
 (defvar gnus-agent-send-mail-function nil)
-(defvar gnus-agent-file-coding-system 'no-conversion)
+(defvar gnus-agent-file-coding-system 'binary)
 
 (defconst gnus-agent-scoreable-headers
   (list


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

* Re: MIME decoding broken on Win NT
  1998-11-23 21:03 ` Shenghuo ZHU
@ 1998-11-24 10:15   ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Magne Ingebrigtsen @ 1998-11-24 10:15 UTC (permalink / raw)


Shenghuo ZHU <zsh@cs.rochester.edu> writes:

> MA> !                  'buffer-file-coding-system
>                        ^ Should this single quote be deleted?

Yup; I've deleted that quote in 0.54.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


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

* Re: MIME decoding broken on Win NT
  1998-11-24  8:50 ` Shenghuo ZHU
@ 1998-11-24 19:13   ` Matt Armstrong
  1998-11-24 19:31     ` Shenghuo ZHU
  0 siblings, 1 reply; 7+ messages in thread
From: Matt Armstrong @ 1998-11-24 19:13 UTC (permalink / raw)
  Cc: ding

Shenghuo ZHU <zsh@cs.rochester.edu> writes:

> +	* mm-util.el (mm-with-unibyte-buffer): Use binary instead of nil.

This has fixed the problem.  Exported binary files are no longer
corrupt under WinNT.  Thanks!


> mm-with-binary-buffer seems to be a better name than
> mm-with-unibyte-buffer.

I thought the same.  In fact, I didn't make the change you made above
because I thought "unibyte" meant something special and not just
binary.


-- 
matta



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

* Re: MIME decoding broken on Win NT
  1998-11-24 19:13   ` Matt Armstrong
@ 1998-11-24 19:31     ` Shenghuo ZHU
  1998-11-24 20:19       ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Shenghuo ZHU @ 1998-11-24 19:31 UTC (permalink / raw)


>>>>> "Matt" == Matt Armstrong <matta@geoworks.com> writes:

Matt> Shenghuo ZHU <zsh@cs.rochester.edu> writes:
>> +	* mm-util.el (mm-with-unibyte-buffer): Use binary instead of nil.

Matt> This has fixed the problem.  Exported binary files are no longer
Matt> corrupt under WinNT.  Thanks!

This make situation more complicated. Kai Grossjohann reported that it
did not work in Gnu Emacs, at least some ugly message displayed. What
happens in XEmacs?

>> mm-with-binary-buffer seems to be a better name than
>> mm-with-unibyte-buffer.

Matt> I thought the same.  In fact, I didn't make the change you made
Matt> above because I thought "unibyte" meant something special and
Matt> not just binary.

Lars, any comments?

-- 
Shenghuo


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

* Re: MIME decoding broken on Win NT
  1998-11-24 19:31     ` Shenghuo ZHU
@ 1998-11-24 20:19       ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Magne Ingebrigtsen @ 1998-11-24 20:19 UTC (permalink / raw)


Shenghuo ZHU <zsh@cs.rochester.edu> writes:

> Matt> I thought the same.  In fact, I didn't make the change you made
> Matt> above because I thought "unibyte" meant something special and
> Matt> not just binary.
> 
> Lars, any comments?

The important thing about the macro is that it executes in a unibyte
buffer; the actual coding system is less important.  (If it isn't a
unibyte buffer, the Emacs base64 code does not do what one would think
it does.)  So I think the name is ok as it is now.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


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

end of thread, other threads:[~1998-11-24 20:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-23 20:51 MIME decoding broken on Win NT Matt Armstrong
1998-11-23 21:03 ` Shenghuo ZHU
1998-11-24 10:15   ` Lars Magne Ingebrigtsen
1998-11-24  8:50 ` Shenghuo ZHU
1998-11-24 19:13   ` Matt Armstrong
1998-11-24 19:31     ` Shenghuo ZHU
1998-11-24 20:19       ` Lars Magne Ingebrigtsen

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 NNTP newsgroup(s).