From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/59836 Path: main.gmane.org!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.gnus.general Subject: Re: Reply misinterprets Commas in encoded-words (Gnus violates RFC Date: Fri, 18 Feb 2005 16:32:01 +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 1108712135 17317 80.91.229.2 (18 Feb 2005 07:35:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 18 Feb 2005 07:35:35 +0000 (UTC) Cc: Stefan Wiens Original-X-From: ding-owner+M8377@lists.math.uh.edu Fri Feb 18 08:35:35 2005 Original-Received: from malifon.math.uh.edu ([129.7.128.13] ident=mail) by ciao.gmane.org with esmtp (Exim 4.43) id 1D22fe-0000Uw-DE for ding-account@gmane.org; Fri, 18 Feb 2005 08:35:26 +0100 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 1D22cz-0005AL-00; Fri, 18 Feb 2005 01:32:41 -0600 Original-Received: from util2.math.uh.edu ([129.7.128.23]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1D22cf-0005AF-00 for ding@lists.math.uh.edu; Fri, 18 Feb 2005 01:32:21 -0600 Original-Received: from quimby.gnus.org ([80.91.224.244]) by util2.math.uh.edu with esmtp (Exim 4.30) id 1D22cc-0002Tf-CM for ding@lists.math.uh.edu; Fri, 18 Feb 2005 01:32:18 -0600 Original-Received: from washington.hostforweb.net ([69.61.11.2]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1D22cb-0008Co-00 for ; Fri, 18 Feb 2005 08:32:17 +0100 Original-Received: from localhost ([127.0.0.1]) by washington.hostforweb.net with esmtpa (Exim 4.44) id 1D22ca-0002ZB-2u; Fri, 18 Feb 2005 02:32:16 -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.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:yUyiyg2Co54nOxFeJ7TpANF7SpQ= X-Hashcash: 1:20:050218:ding@gnus.org::svDD023olH8GDzGB:00002GEs X-Hashcash: 1:20:050218:s.wi@gmx.net::NNT3IwwhZ6oaz/DH:000005TWi X-Antivirus-Scanner: Clean mail though you should still use an Antivirus 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.8 (----) Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu X-MailScanner-From: ding-owner+m8377@lists.math.uh.edu X-MailScanner-To: ding-account@gmane.org Xref: main.gmane.org gmane.emacs.gnus.general:59836 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:59836 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable >>>>> In Reiner Steib wrote: > On Thu, Feb 17 2005, Katsumi Yamaoka wrote: >> From: Wiens, Stef=AAn >> >> I wrote that it seems to be difficult to parse. > Would it be possible to build the (Reply) headers from the original > (undecoded) article? That is what I just wrote that it seems to be difficult. ;-) > My impression is that this would be necessary in order to fix the > problem. I agree. Today I found a better way to fix the problem without modifying the rfc2047 encoder. It doesn't require to modify the way to build the reply headers either. The solution is to quote decoded words in the " *gnus article copy*" buffer (in which the reply headers are extracted) if there are special characters. The new patch for the trunk is below. > There are some problems with this patch. After applying your patch, I > see the *encoded* From in the Summary and Article buffer: >| From: =3D?iso-8859-1?q?Wiens=3D2C_Stef=3DAAn?=3D Eh?, that's strange. I've modified neither the decoder nor the core of the encoder, hmm..., but now, let's junk it anyway. I'm sorry to have waste your time. * gnus-msg.el (gnus-copy-article-buffer): Quote decoded words containing special characters. * rfc2047.el (rfc2047-encode-parameter): Use ietf-drums-tspecials. (rfc2047-quote-decoded-words-containing-tspecials): New variable. (rfc2047-decode-region): Quote decoded words containing special characters when rfc2047-quote-decoded-words-containing-tspecials is non-nil. --=-=-= Content-Type: text/x-patch Content-Disposition: inline --- gnus-msg.el~ 2005-02-13 21:48:03 +0000 +++ gnus-msg.el 2005-02-18 07:23:24 +0000 @@ -878,7 +878,8 @@ ;; Decode charsets. (let ((gnus-article-decode-hook (delq 'article-decode-charset - (copy-sequence gnus-article-decode-hook)))) + (copy-sequence gnus-article-decode-hook))) + (rfc2047-quote-decoded-words-containing-tspecials t)) (run-hooks 'gnus-article-decode-hook))))) gnus-article-copy))) --- rfc2047.el~ 2004-11-23 21:49:55 +0000 +++ rfc2047.el 2005-02-18 07:23:24 +0000 @@ -35,6 +35,7 @@ (require 'qp) (require 'mm-util) +(require 'ietf-drums) ;; Fixme: Avoid this (used for mail-parse-charset) mm dependence on gnus. (require 'mail-prsvr) (require 'base64) @@ -766,8 +767,7 @@ (let* ((rfc2047-encoding-type 'mime) (rfc2047-encode-max-chars nil) (string (rfc2047-encode-string value))) - (if (string-match "[][()<>@,;:\\\"/?=]" ;; tspecials - string) + (if (string-match (concat "[" ietf-drums-tspecials "]") string) (format "%s=%S" param string) (concat param "=" string)))) @@ -780,6 +780,9 @@ "=\\?\\([^][\000-\040()<>@,\;:*\\\"/?.=]+\\)\\(?:\\*[^?]+\\)?\ \\?\\(B\\|Q\\)\\?\\([!->@-~ ]*\\)\\?=")) +(defvar rfc2047-quote-decoded-words-containing-tspecials nil + "If non-nil, quote decoded words containing special characters.") + ;; Fixme: This should decode in place, not cons intermediate strings. ;; Also check whether it needs to worry about delimiting fields like ;; encoding. @@ -814,14 +817,56 @@ (insert (rfc2047-parse-and-decode (prog1 (match-string 0) - (delete-region (match-beginning 0) (match-end 0))))) - ;; Remove newlines between decoded words, though such things - ;; essentially must not be there. + (delete-region e (match-end 0))))) + (while (looking-at rfc2047-encoded-word-regexp) + (insert (rfc2047-parse-and-decode + (prog1 + (match-string 0) + (delete-region (point) (match-end 0)))))) (save-restriction (narrow-to-region e (point)) (goto-char e) + ;; Remove newlines between decoded words, though such + ;; things essentially must not be there. (while (re-search-forward "[\n\r]+" nil t) (replace-match " ")) + (when rfc2047-quote-decoded-words-containing-tspecials + ;; Quote decoded words if there are special characters + ;; which might violate RFC2822. + (let (quoted) + (goto-char e) + (skip-chars-forward " \t") + (setq start (point)) + (setq quoted (eq (char-after) ?\")) + (goto-char (point-max)) + (skip-chars-backward " \t") + (if (setq quoted (and quoted + (> (point) (1+ start)) + (eq (char-before) ?\"))) + (progn + (backward-char) + (setq start (1+ start) + end (point-marker))) + (setq end (point-marker))) + (goto-char start) + (while (search-forward "\"" end t) + (when (prog2 + (backward-char) + (zerop (% (skip-chars-backward "\\\\") 2)) + (goto-char (match-beginning 0))) + (insert "\\")) + (forward-char)) + (when (and (not quoted) + (progn + (goto-char start) + (re-search-forward + (concat "[" ietf-drums-tspecials "]") + end t))) + (goto-char start) + (insert "\"") + (goto-char end) + (insert "\"")) + (set-marker end nil))) (goto-char (point-max))) (when (and (mm-multibyte-p) mail-parse-charset --=-=-=--