From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/69663 Path: news.gmane.org!not-for-mail From: Andreas Seltenreich Newsgroups: gmane.emacs.gnus.general Subject: Re: bad boundary choice in forwarded multipart/signed multipart/mixed Date: Sat, 01 May 2010 09:17:09 +0200 Message-ID: <87y6g46qh6.fsf@gate450.dyndns.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1272698328 1637 80.91.229.12 (1 May 2010 07:18:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 1 May 2010 07:18:48 +0000 (UTC) Cc: ding@gnus.org To: Greg Troxel Original-X-From: ding-owner+M18054@lists.math.uh.edu Sat May 01 09:18:47 2010 connect(): No such file or directory Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O86yK-000748-Cw for ding-account@gmane.org; Sat, 01 May 2010 09:18:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1O86xE-0000tA-0t; Sat, 01 May 2010 02:17:36 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1O86x9-0000sq-Nt for ding@lists.math.uh.edu; Sat, 01 May 2010 02:17:31 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1O86ww-000165-4s for ding@lists.math.uh.edu; Sat, 01 May 2010 02:17:28 -0500 Original-Received: from smtp2.rz.uni-karlsruhe.de ([129.13.185.218] ident=Debian-exim) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1O86wv-0008AN-00 for ; Sat, 01 May 2010 09:17:17 +0200 Original-Received: from rzstud2.stud.uni-karlsruhe.de (rzstud2.stud.uni-karlsruhe.de [193.196.41.42]) by smtp2.rz.uni-karlsruhe.de with esmtps (Exim 4.63 #1) id 1O86wo-0003ER-UF; Sat, 01 May 2010 09:17:11 +0200 Original-Received: from uwi7 by rzstud2.stud.uni-karlsruhe.de with local (Exim 4.63) (envelope-from ) id 1O86wo-0000o4-J4; Sat, 01 May 2010 09:17:10 +0200 In-Reply-To: (Greg Troxel's message of "Thu, 29 Apr 2010 11:11:22 -0400") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.96 (gnu/linux) X-Hashcash: 1:26:100430:ding@gnus.org::KdDpA4sEBNFJIAke:04N2A X-Hashcash: 1:26:100430:gdt@work.lexort.com::Odnt9Q/mao1We9yz:1Fsa4 X-Spam-Score: -3.0 (---) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:69663 Archived-At: --=-=-= Greg Troxel writes: > The inner test message had boundary =-=-= originally. That got remapped > whent he message was forwarded, which I suppose is ok. Yeah, Gnus is a bit eager with regenerating MIME (you can tame it using message-forward-show-mml). > But it got remaped to ===-=-= and that's the same value that was > chosen for the outer message's multipart/signed. [...] > It looks like the key code is in mml.el in gnus, but I haven't > understood it yet. My analysis so far: (a) mml-multipart-number is let-bound on recursive descend of mml-generate-mime. So mml-compute-boundary potentially generates duplicate delimiters unless the collision test prevents it. (b) The collision test code doesn't look at the content of message/rfc822 [#mml] handles. (c) If it would look at them, it wouldn't note a collision generated by (a) since the handle still contains the untranslated [#multipart]-tags instead of MIME. I think (b) needs to be fixed anyway because a collision could occur independently of (a). Now either fixing (a) or (c) should prevent the generation of broken MIME. I guess squishing the bug the (b) + (c) way is more adequate since it's less invasive. Will push in a jiffy. Thanks for your elaborate report, andreas --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/lisp/mml.el b/lisp/mml.el index f262dc6..9dc0966 100644 --- a/lisp/mml.el +++ b/lisp/mml.el @@ -520,7 +520,10 @@ (defun mml-generate-mime-1 (cont) ;; `m-g-d-t' will be bound to "message/rfc822" ;; when encoding an article to be forwarded. (mml-generate-default-type "text/plain")) - (mml-to-mime)) + (mml-to-mime) + ;; Update handle so mml-compute-boundary can + ;; detect collisions with the nested parts. + (setcdr (assoc 'contents cont) (buffer-string))) (let ((mm-7bit-chars (concat mm-7bit-chars "\x1b"))) ;; ignore 0x1b, it is part of iso-2022-jp (setq encoding (mm-body-7-or-8)))) @@ -699,7 +702,7 @@ (defun mml-compute-boundary (cont) (defun mml-compute-boundary-1 (cont) (let (filename) (cond - ((eq (car cont) 'part) + ((member (car cont) '(part mml)) (with-temp-buffer (cond ((cdr (assq 'buffer cont)) --=-=-=--