From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/68954 Path: news.gmane.org!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.gnus.general Subject: Re: application/octet-stream sent as 7bit Date: Fri, 04 Sep 2009 09:31:31 +0900 Organization: Emacsen advocacy group Message-ID: References: <87zl9hpgeu.fsf@paduch.telenet.ru> <87ws4gnho3.fsf@paduch.telenet.ru> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1252024430 12055 80.91.229.12 (4 Sep 2009 00:33:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Sep 2009 00:33:50 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M17372@lists.math.uh.edu Fri Sep 04 02:33:42 2009 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.50) id 1MjMkI-0001tw-Eu for ding-account@gmane.org; Fri, 04 Sep 2009 02:33:42 +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 1MjMjF-0008IF-EA; Thu, 03 Sep 2009 19:32:37 -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 1MjMjB-0008I0-2d for ding@lists.math.uh.edu; Thu, 03 Sep 2009 19:32:33 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1MjMix-0002mV-DK for ding@lists.math.uh.edu; Thu, 03 Sep 2009 19:32:33 -0500 Original-Received: from orlando.hostforweb.net ([216.246.45.90]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1MjMjY-0004D0-00 for ; Fri, 04 Sep 2009 02:32:56 +0200 Original-Received: from localhost ([127.0.0.1]:45298) by orlando.hostforweb.net with esmtpa (Exim 4.69) (envelope-from ) id 1MjMiD-0003k1-S1 for ding@gnus.org; Thu, 03 Sep 2009 19:31:37 -0500 X-Hashcash: 1:20:090904:ding@gnus.org::F3wao+0q0l+FAWOv:0000325w 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.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:uKrmuTkRDkJjJIpwzoVqbxMIdpk= X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - orlando.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: -2.6 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:68954 Archived-At: --=-=-= >>>>> Dmitri Paduchikh wrote: [...] >> Agreed. Aren't there any other application/* types that should >> not be forced to be encoded by 7bit? Otherwise, is it better not >> to force the 7bit encoding to all application/* types? > Hmm... It is unclear to me whether other application/* (or audio/*, > image/*, video/*) require protection from this behavior. Although binary > data most likely isn't 7-bit, it may be 7-bit in principle. IMO, in such > case it would be preferable to provide safe default behavior and means > to change it if user wants to. 7bit enforcement breaks both of these > principles (safe default and user control) thus I would rather remove it > completely as in the patch below. Are there any situations when it is > desirable to enforce 7bit? >> Here are two patches; one is for excluding application/octet-stream, >> the other is for excluding application/*. > Thank you. The following patch is a variation of your patches. [...] I like it. I think removing the 7bit enforcement makes it simple, necessary and sufficient. Even so, it can be controlled by customizing `mm-content-transfer-encoding-defaults' if necessary (though I don't think so). I'd like to make one more change, which enables a user to change the encoding by adding the `encoding=' component to a MIME tag manually like this: < #part type="application/octet-stream" disposition=inline encoding=7bit> It will be useful for testing with various encodings. The patch: --=-=-= Content-Type: text/x-patch Content-Disposition: inline --- mm-encode.el~ 2009-01-22 08:09:02 +0000 +++ mm-encode.el 2009-09-04 00:28:48 +0000 @@ -137,22 +137,19 @@ (t (error "Unknown encoding %s" encoding)))) -(defun mm-encode-buffer (type) - "Encode the buffer which contains data of MIME type TYPE. +(defun mm-encode-buffer (type &optional encoding) + "Encode the buffer which contains data of MIME type TYPE by ENCODING. TYPE is a string or a list of the components. +The optional ENCODING overrides the encoding determined according to +TYPE and `mm-content-transfer-encoding-defaults'. The encoding used is returned." - (let* ((mime-type (if (stringp type) type (car type))) - (encoding - (or (and (listp type) - (cadr (assq 'encoding type))) - (mm-content-transfer-encoding mime-type))) - (bits (mm-body-7-or-8))) - ;; We force buffers that are 7bit to be unencoded, no matter - ;; what the preferred encoding is. - ;; Only if the buffers don't contain lone lines. - (when (and (eq bits '7bit) (not (mm-long-lines-p 76))) - (setq encoding bits)) - (mm-encode-content-transfer-encoding encoding mime-type) + (let ((mime-type (if (stringp type) type (car type)))) + (mm-encode-content-transfer-encoding + (or encoding + (setq encoding (or (and (listp type) + (cadr (assq 'encoding type))) + (mm-content-transfer-encoding mime-type)))) + mime-type) encoding)) (defun mm-insert-headers (type encoding &optional file) --- mml.el~ 2009-08-31 00:08:11 +0000 +++ mml.el 2009-09-04 00:28:48 +0000 @@ -585,7 +585,9 @@ (unless raw (setq charset (mm-encode-body charset)))) (insert contents))))) - (setq encoding (mm-encode-buffer type) + (if (setq encoding (cdr (assq 'encoding cont))) + (setq encoding (intern (downcase encoding)))) + (setq encoding (mm-encode-buffer type encoding) coded (mm-string-as-multibyte (buffer-string)))) (mml-insert-mime-headers cont type charset encoding nil) (insert "\n" coded)))) --=-=-=--