;;; mm-bodies.el --- Functions for decoding MIME things
-;; Copyright (C) 1998,99 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
;; BS, vertical TAB, form feed, and ^_
(defvar mm-7bit-chars "\x20-\x7f\r\n\t\x7\x8\xb\xc\x1f")
-(defvar mm-body-charset-encoding-alist nil
+(defcustom mm-body-charset-encoding-alist
+ '((iso-2022-jp . 7bit)
+ (iso-2022-jp-2 . 7bit))
"Alist of MIME charsets to encodings.
-Valid encodings are `7bit', `8bit', `quoted-printable' and `base64'.")
+Valid encodings are `7bit', `8bit', `quoted-printable' and `base64'."
+ :type '(repeat (cons (symbol :tag "charset")
+ (choice :tag "encoding"
+ (const 7bit)
+ (const 8bit)
+ (const quoted-printable)
+ (const base64))))
+ :group 'mime)
(defun mm-encode-body ()
"Encode a body.
(not (mm-coding-system-equal
charset buffer-file-coding-system)))
(while (not (eobp))
- (if (eq (char-charset (char-after)) 'ascii)
+ (if (eq (mm-charset-after) 'ascii)
(when start
(save-restriction
(narrow-to-region start (point))
(cond
((eq bits '7bit)
bits)
- ((eq charset mail-parse-charset)
+ ((and (not mm-use-ultra-safe-encoding)
+ (or (eq t (cdr message-posting-charset))
+ (memq charset (cdr message-posting-charset))
+ (eq charset mail-parse-charset)))
bits)
(t
(let ((encoding (or encoding
(cdr (assq charset mm-body-charset-encoding-alist))
(mm-qp-or-base64))))
+ (when mm-use-ultra-safe-encoding
+ (setq encoding (mm-safer-encoding encoding)))
(mm-encode-content-transfer-encoding encoding "text/plain")
encoding)))))
((eq encoding 'quoted-printable)
(quoted-printable-decode-region (point-min) (point-max)))
((eq encoding 'base64)
- (base64-decode-region (point-min)
- ;; Some mailers insert whitespace
- ;; junk at the end which
- ;; base64-decode-region dislikes.
- (save-excursion
- (goto-char (point-max))
- (skip-chars-backward "\n\t ")
- (delete-region (point) (point-max))
- (point))))
+ (base64-decode-region
+ (point-min)
+ ;; Some mailers insert whitespace
+ ;; junk at the end which
+ ;; base64-decode-region dislikes.
+ ;; Also remove possible junk which could
+ ;; have been added by mailing list software.
+ (save-excursion
+ (goto-char (point-min))
+ (if (re-search-forward "^[\t ]*$" nil t)
+ (delete-region (point) (point-max))
+ (goto-char (point-max)))
+ (skip-chars-backward "\n\t ")
+ (delete-region (point) (point-max))
+ (point))))
((memq encoding '(7bit 8bit binary))
;; Do nothing.
)