changeset 88314:6ec464007704

(rmail-mime-media-type-handlers-alist): Removed non-existing handlers for the moment. (rmail-mime-text-handler): Do decoding based on the charset parameter. (test-rmail-mime-handler): Test decoding using an 8bit KOI8 message. (rmail-mime-handle): Switch to unibyte if content transfer encoding is 8bit. Strange that it should be necessary.
author Alex Schroeder <alex@gnu.org>
date Tue, 07 Feb 2006 00:19:02 +0000
parents 9bc194463f63
children db0e12d3694b
files lisp/mail/rmailmm.el
diffstat 1 files changed, 27 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/rmailmm.el	Fri Feb 03 23:10:50 2006 +0000
+++ b/lisp/mail/rmailmm.el	Tue Feb 07 00:19:02 2006 +0000
@@ -34,20 +34,15 @@
 
 (defcustom rmail-mime-media-type-handlers-alist
   '(("multipart/.*" rmail-mime-multipart-handler)
-    ("message/rfc822" rmail-mime-toggler-handler)
-    ("message/delivery-status" rmail-mime-entity-hider-handler)
-    ("message/x-body" rmail-mime-entity-hider-handler)
-    ("message/x-command-input" rmail-mime-message/x-command-input-handler)
-    ("message/external-body" rmail-mime-message/external-body-handler)
     ("text/.*" rmail-mime-text-handler)
     ("text/\\(x-\\)?patch" rmail-mime-bulk-handler)
-    ("image/.*" rmail-mime-image-handler)
     ("application/pgp-signature" rmail-mime-application/pgp-signature-handler)
     ("\\(image\\|audio\\|video\\|application\\)/.*" rmail-mime-bulk-handler))
   "Alist of media type handlers, also known as agents.
 Every handler is a list of type (string symbol) where STRING is a
 regular expression to match the media type with and SYMBOL is a
-function to run."
+function to run.  Handlers should return a non-nil value if the
+job is done."
   :type 'list
   :group 'mime)
 
@@ -101,7 +96,26 @@
 (defun rmail-mime-text-handler (content-type
 				content-disposition
 				content-transfer-encoding)
-  "Handle the current buffer as a plain text MIME part.")
+  "Handle the current buffer as a plain text MIME part."
+  (let* ((charset (cdr (assq 'charset (cdr content-type))))
+	 (coding-system (intern (downcase charset))))
+    (when (coding-system-p coding-system)
+      (decode-coding-region (point-min) (point-max) coding-system))))
+
+(defun test-rmail-mime-handler ()
+  "Test of a mail using no MIME parts at all."
+  (let ((mail "To: alex@gnu.org
+Content-Type: text/plain; charset=koi8-r
+Content-Transfer-Encoding: 8bit
+MIME-Version: 1.0
+
+\372\304\322\301\327\323\324\327\325\312\324\305\41"))
+    (switch-to-buffer (get-buffer-create "*test*"))
+    (erase-buffer)
+    (set-buffer-multibyte nil)
+    (insert mail)
+    (rmail-mime-show t)
+    (set-buffer-multibyte t)))
 
 (defun rmail-mime-bulk-handler (content-type
 				content-disposition
@@ -270,7 +284,10 @@
 	 (setq content-transfer-encoding nil))
 	((string= content-transfer-encoding "quoted-printable")
 	 (quoted-printable-decode-region (point-min) (point-max))
-	 (setq content-transfer-encoding nil)))
+	 (setq content-transfer-encoding nil))
+	((string= content-transfer-encoding "8bit")
+	 ;; FIXME: Is this the correct way?
+	 (set-buffer-multibyte nil)))
   ;; Inline stuff requires work.  Attachments are handled by the bulk
   ;; handler.
   (if (string= "inline" (car content-disposition))
@@ -294,7 +311,7 @@
 called recursively if multiple parts are available.
 
 The current buffer must contain a single message.  It will be
-modifed."
+modified."
   (let ((end (point-min))
 	content-type
 	content-transfer-encoding