From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/60639 Path: news.gmane.org!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.gnus.general Subject: Re: mml-attach-file: Argument TYPE is not optional Date: Wed, 27 Jul 2005 10:37:13 +0900 Organization: Emacsen advocacy group Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1122494569 7539 80.91.229.2 (27 Jul 2005 20:02:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 27 Jul 2005 20:02:49 +0000 (UTC) Original-X-From: ding-owner+M9167@lists.math.uh.edu Wed Jul 27 22:02:48 2005 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Dxs6I-00015V-5h for ding-account@gmane.org; Wed, 27 Jul 2005 22:01:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu ident=lists) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1DxbAF-0001pj-00; Tue, 26 Jul 2005 20:56:55 -0500 Original-Received: from util2.math.uh.edu ([129.7.128.23]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1DxarR-0001nc-00 for ding@lists.math.uh.edu; Tue, 26 Jul 2005 20:37:29 -0500 Original-Received: from quimby.gnus.org ([80.91.224.244]) by util2.math.uh.edu with esmtp (Exim 4.30) id 1DxarP-0001Vh-Mj for ding@lists.math.uh.edu; Tue, 26 Jul 2005 20:37:27 -0500 Original-Received: from washington.hostforweb.net ([66.225.201.13]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1DxarO-0006Fm-00 for ; Wed, 27 Jul 2005 03:37:26 +0200 Original-Received: from localhost.servershost.net ([127.0.0.1] helo=localhost) by washington.hostforweb.net with esmtpa (Exim 4.50) id 1DxarV-0005XG-IU for ding@gnus.org; Tue, 26 Jul 2005 20:37:33 -0500 Original-To: ding@gnus.org X-Face: #kKnN,xUnmKia.'[pp`;Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu;B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw= L&i*6&( User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:yaQ7XIPW130PLR9kzXWvahcAF60= X-Hashcash: 1:20:050727:ding@gnus.org::vEQMy9c8S3/c3vcl:000078nc X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - washington.hostforweb.net X-AntiAbuse: Original Domain - gnus.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - jpl.org X-Source: X-Source-Args: X-Source-Dir: X-Spam-Score: -4.9 (----) Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu Xref: news.gmane.org gmane.emacs.gnus.general:60639 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:60639 --=-=-= >>>>> In Reiner Steib wrote: > the doc string of `mml-attach-file' says that TYPE is optional: And also for `mml-attach-external'. [...] > After evaluating (mml-attach-file "/tmp/ste/gnus/test-file-1.txt") in > a message buffer, I get: >| <# part filename="/tmp/ste/gnus/test-file-1.txt" disposition=attachment> >| <# /part> > Note: type="text/plain" is not specified. It is the same in the case where `mml-attach-external' is used. > When sending the message, I get the backtrace listed below[1]. Aren't you talking about `mml-attach-external'? Though I couldn't reproduce the error because the type defaults to text/plain for the <# part ...>s internally in `mml-generate-mime-1', I think it isn't good that Gnus doesn't add the Content-Type MIME header to the part anyway, and the default type should be application/octet-stream if it cannot be guessed. > I'm not sure about the best way to fix this problem: > (1) Make TYPE in `mml-attach-file' mandatory. > (2) Set Content-Type in `mml-generate-mime-1' appropriately if no > type=".../..." is specified. > Patch for solution (2): [...] > Opinions? Unless there are other suggestion, I'll install (2). I vote to (2). Here're patches for the v5-10 branch and for the trunk, which enable to add the Content-Type header for the <# part ...>s as well. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v5-10.patch --- mml.el~ 2005-07-24 21:54:30 +0000 +++ mml.el 2005-07-27 01:34:21 +0000 @@ -400,9 +400,12 @@ (mml-tweak-part cont) (cond ((or (eq (car cont) 'part) (eq (car cont) 'mml)) - (let ((raw (cdr (assq 'raw cont))) - coded encoding charset filename type flowed) - (setq type (or (cdr (assq 'type cont)) "text/plain")) + (let* ((raw (cdr (assq 'raw cont))) + (filename (cdr (assq 'filename cont))) + (type (or (cdr (assq 'type cont)) + (and filename (mm-default-file-encoding filename)) + "application/octet-stream")) + coded encoding charset flowed) (if (and (not raw) (member (car (split-string type "/")) '("text" "message"))) (progn @@ -414,7 +417,7 @@ (cond ((cdr (assq 'buffer cont)) (insert-buffer-substring (cdr (assq 'buffer cont)))) - ((and (setq filename (cdr (assq 'filename cont))) + ((and filename (not (equal (cdr (assq 'nofile cont)) "yes"))) (let ((coding-system-for-read charset)) (mm-insert-file-contents filename))) @@ -475,7 +478,7 @@ (insert (with-current-buffer (cdr (assq 'buffer cont)) (mm-with-unibyte-current-buffer (buffer-string))))) - ((and (setq filename (cdr (assq 'filename cont))) + ((and filename (not (equal (cdr (assq 'nofile cont)) "yes"))) (let ((coding-system-for-read mm-binary-coding-system)) (mm-insert-file-contents filename nil nil nil nil t))) @@ -516,15 +519,19 @@ "access-type=url")) (when parameters (mml-insert-parameter-string - cont '(expiration size permission)))) - (insert "\n\n") - (insert "Content-Type: " (cdr (assq 'type cont)) "\n") - (insert "Content-ID: " (message-make-message-id) "\n") - (insert "Content-Transfer-Encoding: " - (or (cdr (assq 'encoding cont)) "binary")) - (insert "\n\n") - (insert (or (cdr (assq 'contents cont)))) - (insert "\n")) + cont '(expiration size permission))) + (insert "\n\n") + (insert "Content-Type: " + (or (cdr (assq 'type cont)) + (and name (mm-default-file-encoding name)) + "application/octet-stream") + "\n") + (insert "Content-ID: " (message-make-message-id) "\n") + (insert "Content-Transfer-Encoding: " + (or (cdr (assq 'encoding cont)) "binary")) + (insert "\n\n") + (insert (or (cdr (assq 'contents cont)))) + (insert "\n"))) ((eq (car cont) 'multipart) (let* ((type (or (cdr (assq 'type cont)) "mixed")) (mml-generate-default-type (if (equal type "digest") @@ -560,7 +567,8 @@ (message-options-set 'message-sender sender)) (if (setq recipients (cdr (assq 'recipients cont))) (message-options-set 'message-recipients recipients)) - (let ((style (mml-signencrypt-style (first (or sign-item encrypt-item))))) + (let ((style (mml-signencrypt-style + (first (or sign-item encrypt-item))))) ;; check if: we're both signing & encrypting, both methods ;; are the same (why would they be different?!), and that ;; the signencrypt style allows for combined operation. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=trunk.patch --- mml.el~ 2005-07-24 21:50:41 +0000 +++ mml.el 2005-07-27 01:34:21 +0000 @@ -404,11 +404,14 @@ (mml-tweak-part cont) (cond ((or (eq (car cont) 'part) (eq (car cont) 'mml)) - (let ((raw (cdr (assq 'raw cont))) - type charset coding filename encoding flowed coded) - (setq type (or (cdr (assq 'type cont)) "text/plain") - charset (cdr (assq 'charset cont)) - coding (mm-charset-to-coding-system charset)) + (let* ((raw (cdr (assq 'raw cont))) + (filename (cdr (assq 'filename cont))) + (type (or (cdr (assq 'type cont)) + (and filename (mm-default-file-encoding filename)) + "application/octet-stream")) + (charset (cdr (assq 'charset cont))) + (coding (mm-charset-to-coding-system charset)) + encoding flowed coded) (cond ((eq coding 'ascii) (setq charset nil coding nil)) @@ -421,7 +424,7 @@ (cond ((cdr (assq 'buffer cont)) (insert-buffer-substring (cdr (assq 'buffer cont)))) - ((and (setq filename (cdr (assq 'filename cont))) + ((and filename (not (equal (cdr (assq 'nofile cont)) "yes"))) (let ((coding-system-for-read coding)) (mm-insert-file-contents filename))) @@ -482,7 +485,7 @@ (insert (with-current-buffer (cdr (assq 'buffer cont)) (mm-with-unibyte-current-buffer (buffer-string))))) - ((and (setq filename (cdr (assq 'filename cont))) + ((and filename (not (equal (cdr (assq 'nofile cont)) "yes"))) (let ((coding-system-for-read mm-binary-coding-system)) (mm-insert-file-contents filename nil nil nil nil t)) @@ -527,15 +530,19 @@ "access-type=url")) (when parameters (mml-insert-parameter-string - cont '(expiration size permission)))) - (insert "\n\n") - (insert "Content-Type: " (cdr (assq 'type cont)) "\n") - (insert "Content-ID: " (message-make-message-id) "\n") - (insert "Content-Transfer-Encoding: " - (or (cdr (assq 'encoding cont)) "binary")) - (insert "\n\n") - (insert (or (cdr (assq 'contents cont)))) - (insert "\n")) + cont '(expiration size permission))) + (insert "\n\n") + (insert "Content-Type: " + (or (cdr (assq 'type cont)) + (and name (mm-default-file-encoding name)) + "application/octet-stream") + "\n") + (insert "Content-ID: " (message-make-message-id) "\n") + (insert "Content-Transfer-Encoding: " + (or (cdr (assq 'encoding cont)) "binary")) + (insert "\n\n") + (insert (or (cdr (assq 'contents cont)))) + (insert "\n"))) ((eq (car cont) 'multipart) (let* ((type (or (cdr (assq 'type cont)) "mixed")) (mml-generate-default-type (if (equal type "digest") --=-=-=--