summaryrefslogtreecommitdiff
path: root/lisp/gnus
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2008-03-12 18:30:52 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2008-03-12 18:30:52 +0000
commitd4eb2b7e39d6b6ee1bee4be0b0d53a3f3202da5a (patch)
treef2ee38b568448d332618928fb669f523c692d141 /lisp/gnus
parent228b6ecd21215cfb3296a643fb8fe065b1683c42 (diff)
downloademacs-d4eb2b7e39d6b6ee1bee4be0b0d53a3f3202da5a.tar.gz
emacs-d4eb2b7e39d6b6ee1bee4be0b0d53a3f3202da5a.tar.bz2
emacs-d4eb2b7e39d6b6ee1bee4be0b0d53a3f3202da5a.zip
(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.
Diffstat (limited to 'lisp/gnus')
-rw-r--r--lisp/gnus/ChangeLog4
-rw-r--r--lisp/gnus/mm-decode.el26
2 files changed, 16 insertions, 14 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index e1ea5e7c6c5..21d531f59f7 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,5 +1,9 @@
2008-03-12 Stefan Monnier <monnier@iro.umontreal.ca>
+ * mm-decode.el (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.
+
* gnus-msg.el: Use with-current-buffer.
* message.el (message-ignored-resent-headers): Add "Delivered-To".
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index 46bf4b8d8fe..331174ef2cf 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -663,11 +663,11 @@ Postpone undisplaying of viewers for types in
(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 @@ in HANDLE."
(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
- (insert-buffer-substring (mm-handle-buffer handle))
(mm-disable-multibyte)
+ (insert-buffer-substring (mm-handle-buffer handle))
(mm-decode-content-transfer-encoding
(mm-handle-encoding handle)
(mm-handle-media-type handle))