- (set (make-local-variable 'rmail-header-style) header-style)
- (erase-buffer))
- (if (null character-coding)
- ;; Do it directly since that is fast.
- (rmail-decode-region body-start end coding-system view-buf)
- ;; Can this be done directly, skipping the temp buffer?
- (with-temp-buffer
- (set-buffer-multibyte nil)
- (insert-buffer-substring mbox-buf body-start end)
- (cond
- ((string= character-coding "quoted-printable")
- (mail-unquote-printable-region (point-min) (point-max)))
- ((and (string= character-coding "base64") is-text-message)
- (base64-decode-region (point-min) (point-max)))
- ((eq character-coding 'uuencode)
- (error "uuencoded messages are not supported yet"))
- (t))
- (rmail-decode-region (point-min) (point-max)
- coding-system view-buf)))
- (with-current-buffer rmail-view-buffer
- ;; Unquote quoted From lines
- (goto-char (point-min))
- (while (re-search-forward "^>+From " nil t)
- (beginning-of-line)
- (delete-char 1)
- (forward-line))
- (goto-char (point-min)))
- ;; Copy the headers to the front of the message view buffer.
- (rmail-copy-headers beg end)
- ;; Add the separator (blank line) between headers and body;
+ (set (make-local-variable 'rmail-header-style) header-style))
+ (if (and rmail-enable-mime
+ (re-search-forward "mime-version: 1.0" nil t))
+ (let ((rmail-buffer mbox-buf)
+ (rmail-view-buffer view-buf))
+ (funcall rmail-show-mime-function))
+ (setq body-start (search-forward "\n\n" nil t))
+ (narrow-to-region beg (point))
+ (goto-char beg)
+ (save-excursion
+ (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
+ (setq coding-system (intern (match-string 1)))
+ (setq coding-system (rmail-get-coding-system))))
+ (setq character-coding (mail-fetch-field "content-transfer-encoding")
+ is-text-message (rmail-is-text-p))
+ (if character-coding
+ (setq character-coding (downcase character-coding)))
+ (narrow-to-region beg end)
+ ;; Decode the message body into an empty view buffer using a
+ ;; unibyte temporary buffer where the character decoding takes
+ ;; place.
+ (with-current-buffer rmail-view-buffer
+ (erase-buffer))
+ (if (null character-coding)
+ ;; Do it directly since that is fast.
+ (rmail-decode-region body-start end coding-system view-buf)
+ ;; Can this be done directly, skipping the temp buffer?
+ (with-temp-buffer
+ (set-buffer-multibyte nil)
+ (insert-buffer-substring mbox-buf body-start end)
+ (cond
+ ((string= character-coding "quoted-printable")
+ ;; See bug#5441.
+ (or (mail-unquote-printable-region (point-min) (point-max)
+ nil t 'unibyte)
+ (message "Malformed MIME quoted-printable message")))
+ ((and (string= character-coding "base64") is-text-message)
+ (condition-case err
+ (base64-decode-region (point-min) (point-max))
+ (error (message "%s" (cdr err)))))
+ ((eq character-coding 'uuencode)
+ (error "uuencoded messages are not supported yet"))
+ (t))
+ (rmail-decode-region (point-min) (point-max)
+ coding-system view-buf)))
+ (with-current-buffer rmail-view-buffer
+ ;; Prepare the separator (blank line) before the body.
+ (goto-char (point-min))
+ (insert "\n")
+ ;; Unquote quoted From lines
+ (while (re-search-forward "^>+From " nil t)
+ (beginning-of-line)
+ (delete-char 1)
+ (forward-line))
+ (goto-char (point-min)))
+ ;; Copy the headers to the front of the message view buffer.
+ (rmail-copy-headers beg end))