Mercurial > emacs
diff lisp/gnus/mm-decode.el @ 92769:734bb318f69e
(mm-with-part): Set the buffer to unibyte before inserting
the handle-buffer's text, so the implicit multibyte->unibyte conversion
uses string-make-unibyte rather than string-as-unibyte.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 12 Mar 2008 18:30:52 +0000 |
parents | d3767aa9ae49 |
children | 3bf6293f3041 |
line wrap: on
line diff
--- a/lisp/gnus/mm-decode.el Wed Mar 12 18:23:38 2008 +0000 +++ b/lisp/gnus/mm-decode.el Wed Mar 12 18:30:52 2008 +0000 @@ -663,11 +663,11 @@ (defun mm-copy-to-buffer () "Copy the contents of the current buffer to a fresh buffer." - (let ((obuf (current-buffer)) - beg) - (goto-char (point-min)) - (search-forward-regexp "^\n" nil t) - (setq beg (point)) + (let ((obuf (current-buffer)) + beg) + (goto-char (point-min)) + (search-forward-regexp "^\n" nil t) + (setq beg (point)) (with-current-buffer ;; Preserve the data's unibyteness (for url-insert-file-contents). (let ((default-enable-multibyte-characters (mm-multibyte-p))) @@ -1127,17 +1127,15 @@ (defmacro mm-with-part (handle &rest forms) "Run FORMS in the temp buffer containing the contents of HANDLE." - `(let* ((handle ,handle) - ;; The multibyteness of the temp buffer should be turned on - ;; if inserting a multibyte string. Contrarily, the buffer's - ;; multibyteness should be off if inserting a unibyte string, - ;; especially if a string contains 8bit data. - (default-enable-multibyte-characters - (with-current-buffer (mm-handle-buffer handle) - (mm-multibyte-p)))) + ;; The handle-buffer's content is a sequence of bytes, not a sequence of + ;; chars, so the buffer should be unibyte. It may happen that the + ;; handle-buffer is multibyte for some reason, in which case now is a good + ;; time to adjust it, since we know at this point that it should + ;; be unibyte. + `(let* ((handle ,handle)) (with-temp-buffer + (mm-disable-multibyte) (insert-buffer-substring (mm-handle-buffer handle)) - (mm-disable-multibyte) (mm-decode-content-transfer-encoding (mm-handle-encoding handle) (mm-handle-media-type handle))