X-Git-Url: http://cgit.sxemacs.org/?p=gnus;a=blobdiff_plain;f=lisp%2Fmm-decode.el;h=4a9007a06ecd4d77b4d00de76f54c9233aaabd85;hp=941849da18347eedaa1ee7f1edb3559e1b2a6e06;hb=0a63db68d21591915aa899eabbadb2320edbdb65;hpb=2d5dd67e2129eecf737b8df2f818cd1cabc1c222 diff --git a/lisp/mm-decode.el b/lisp/mm-decode.el index 941849da1..4a9007a06 100644 --- a/lisp/mm-decode.el +++ b/lisp/mm-decode.el @@ -672,12 +672,39 @@ MIME-Version header before proceeding." description))))) (if (or (not ctl) (not (string-match "/" (car ctl)))) - (mm-dissect-singlepart - (list mm-dissect-default-type) - (and cte (intern (downcase (mail-header-strip cte)))) - no-strict-mime - (and cd (mail-header-parse-content-disposition cd)) - description) + (let ((cdl (and cd (mail-header-parse-content-disposition cd)))) + (mm-dissect-singlepart + ;; Guess Content-Type from the file name extention. + ;; Some mailer sends a part without type like this: + ;; Content-Type: ; name="IMG_3156.JPG" + ;; Content-Disposition: attachment; filename="IMG_3156.JPG" + (list (or + (let ((tem + (or (mail-content-type-get cdl 'filename) + (and ct + (with-temp-buffer + (insert ct) + (goto-char (point-min)) + (and (re-search-forward "\ +;[\t\n ]*name=\\([\"']\\|\\([^\t\n\r ]+\\)\\)" nil t) + (or (match-string 2) + (progn + (goto-char (match-beginning 1)) + (condition-case nil + (progn + (forward-sexp 1) + (buffer-substring + (1+ (match-beginning 1)) + (1- (point)))) + (error nil)))))))))) + (and tem + (setq tem (file-name-extension tem)) + (require 'mailcap) + (cdr (assoc (concat "." (downcase tem)) + mailcap-mime-extensions)))) + mm-dissect-default-type)) + (and cte (intern (downcase (mail-header-strip cte)))) + no-strict-mime cdl description)) (setq type (split-string (car ctl) "/")) (setq subtype (cadr type) type (car type))