mm-decode: don't touch MIME type for multipart/encrypted children
authorDaiki Ueno <ueno@unixuser.org>
Thu, 24 May 2012 01:45:38 +0000 (10:45 +0900)
committerDaiki Ueno <ueno@unixuser.org>
Mon, 28 May 2012 04:30:21 +0000 (13:30 +0900)
The commit 1bf64efe introduced auto detection of actual MIME types
for application/octet-stream.  That changes the MIME type of
encrypted part to "text/plain" when it has filename parameter with
".asc", and causes decryption failure.

lisp/ChangeLog
lisp/mm-decode.el

index 00473af..565b10c 100644 (file)
@@ -1,3 +1,12 @@
+2012-05-28  Daiki Ueno  <ueno@unixuser.org>
+
+       * mm-decode.el (mm-inhibit-auto-detect-attachment): New variable.
+       (mm-dissect-singlepart): Don't guess the MIME type of
+       application/octet-stream parts if mm-inhibit-auto-detect-attachment is
+       set.
+       (mm-dissect-multipart): Bind mm-inhibit-auto-detect-attachment if the
+       toplevel MIME type is multipart/encrypted.
+
 2012-05-27  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * gnus-msg.el (gnus-msg-mail): Ensure that gnus-newsgroup-name is
index 8076b2e..de2d1ed 100644 (file)
@@ -458,6 +458,7 @@ If not set, `default-directory' will be used."
 (defvar mm-last-shell-command "")
 (defvar mm-content-id-alist nil)
 (defvar mm-postponed-undisplay-list nil)
+(defvar mm-inhibit-auto-detect-attachment nil)
 
 ;; According to RFC2046, in particular, in a digest, the default
 ;; Content-Type value for a body part is changed from "text/plain" to
@@ -668,7 +669,8 @@ MIME-Version header before proceeding."
     ;; Guess what the type of application/octet-stream parts should
     ;; really be.
     (let ((filename (cdr (assq 'filename (cdr cdl)))))
-      (when (and (equal (car ctl) "application/octet-stream")
+      (when (and (not mm-inhibit-auto-detect-attachment)
+                (equal (car ctl) "application/octet-stream")
                 filename
                 (string-match "\\.\\([^.]+\\)$" filename))
        (let ((new-type (mailcap-extension-to-mime (match-string 1 filename))))
@@ -694,7 +696,9 @@ MIME-Version header before proceeding."
                (goto-char (point-max))
                (if (re-search-backward close-delimiter nil t)
                    (match-beginning 0)
-                 (point-max)))))
+                 (point-max))))
+        (mm-inhibit-auto-detect-attachment
+         (equal (car ctl) "multipart/encrypted")))
     (setq boundary (concat (regexp-quote boundary) "[ \t]*$"))
     (while (and (< (point) end) (re-search-forward boundary end t))
       (goto-char (match-beginning 0))