From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Zhang Wei Newsgroups: gmane.emacs.devel Subject: Re: gnus doesn't encode non-ascii attachment filenames Date: Tue, 14 Feb 2006 09:25:59 +0800 Message-ID: <87irriras8.fsf@emacsfans.org> References: <87bqxbwxoq.fsf@emacsfans.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1139886997 6222 80.91.229.2 (14 Feb 2006 03:16:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 14 Feb 2006 03:16:37 +0000 (UTC) Cc: handa@m17n.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 14 04:16:33 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F8qfj-00024U-4K for ged-emacs-devel@m.gmane.org; Tue, 14 Feb 2006 04:16:13 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F8qfi-0005d9-Gm for ged-emacs-devel@m.gmane.org; Mon, 13 Feb 2006 22:16:10 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F8qLQ-0003Xb-CV for emacs-devel@gnu.org; Mon, 13 Feb 2006 21:55:13 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F8qIj-0000G8-O9 for emacs-devel@gnu.org; Mon, 13 Feb 2006 21:52:30 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F8pz5-0000sC-92 for emacs-devel@gnu.org; Mon, 13 Feb 2006 21:32:07 -0500 Original-Received: from [64.233.166.176] (helo=pproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1F8p1b-0003cy-4Z for emacs-devel@gnu.org; Mon, 13 Feb 2006 20:30:39 -0500 Original-Received: by pproxy.gmail.com with SMTP id s49so942190pyc for ; Mon, 13 Feb 2006 17:25:55 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:to:cc:subject:references:date:in-reply-to:message-id:user-agent:mime-version:content-type; b=dZvy6wMd3h4oIkh6PpNm5cKwq9QFq92lly17TmIlgWSCYp/QR+GWO4Xkv8/h7cZRJHD0z1KnFsEGIhCaMp8XaDdE37fV4b6peQrFVo3b/NqDXDqiFr8F8i+weS2LvFevM/8wvwBAbmvxIM82TAX84ihsECyfBciDtpSt06yTtKE= Original-Received: by 10.35.60.15 with SMTP id n15mr659726pyk; Mon, 13 Feb 2006 17:25:54 -0800 (PST) Original-Received: from emacsfans.org ( [218.56.219.42]) by mx.gmail.com with ESMTP id v53sm169665pyv.2006.02.13.17.25.52; Mon, 13 Feb 2006 17:25:54 -0800 (PST) Original-Received: from zhangwei by emacsfans.org with local (Exim 4.60) (envelope-from ) id 1F8ox5-0007tl-SB; Tue, 14 Feb 2006 09:25:59 +0800 Original-To: rms@gnu.org In-Reply-To: (Richard M. Stallman's message of "Mon, 13 Feb 2006 19:40:06 -0500") User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/23.0.0 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:50500 Archived-At: "Richard M. Stallman" writes: > I suggest you provide a precise test case so people can reproduce the > problem. Sorry, false alarm. This bug is only with the emacs-unicode-2 branch. No problem with emacs 22. The difference of internal character representation between emacs23 and emacs22, makes gnus can't handle non-ascii attachment filename correctly. To generate a rfc2231 encoded filename such as "%d6%d0%ce%c4", function (following-char) returns "d6" for the first char of the filename "d6d0cec4" in emacs22, while in emacs23 this function returns "3fffd6". This is an ugly hack to solve this problem: *** rfc2231.el 08 Feb 2006 20:05:31 +0800 7.13 --- rfc2231.el 14 Feb 2006 09:12:16 +0800 *************** *** 194,207 **** (string-match "\\`\\(?:\\([^']+\\)?'\\([^']+\\)?'\\)?\\(.+\\)" string) (let ((coding-system (mm-charset-to-coding-system (match-string 1 string))) ;;(language (match-string 2 string)) ! (value (match-string 3 string))) (mm-with-multibyte-buffer (insert value) (goto-char (point-min)) (while (search-forward "%" nil t) (insert (prog1 ! (string-to-number (buffer-substring (point) (+ (point) 2)) 16) (delete-region (1- (point)) (+ (point) 2))))) ;; Decode using the charset, if any. (unless (memq coding-system '(nil ascii)) --- 194,213 ---- (string-match "\\`\\(?:\\([^']+\\)?'\\([^']+\\)?'\\)?\\(.+\\)" string) (let ((coding-system (mm-charset-to-coding-system (match-string 1 string))) ;;(language (match-string 2 string)) ! (value (match-string 3 string)) ! number) (mm-with-multibyte-buffer (insert value) (goto-char (point-min)) (while (search-forward "%" nil t) + (setq number (string-to-number (buffer-substring (point) (+ (point) 2)) 16)) (insert (prog1 ! (if (>= emacs-major-version 23) ! (if (> number #x7F) ! (+ number #x3fff00) ! number) ;; why (unibyte-char-to-multibyte ch) does not work? ! number) (delete-region (1- (point)) (+ (point) 2))))) ;; Decode using the charset, if any. (unless (memq coding-system '(nil ascii)) *************** *** 219,226 **** (num -1) ;; Don't make lines exceeding 76 column. (limit (- 74 (length param))) ! spacep encodep charsetp charset broken) ! (with-temp-buffer (insert value) (goto-char (point-min)) (while (not (eobp)) --- 225,232 ---- (num -1) ;; Don't make lines exceeding 76 column. (limit (- 74 (length param))) ! spacep encodep charsetp charset broken following-char) ! (mm-with-multibyte-buffer (insert value) (goto-char (point-min)) (while (not (eobp)) *************** *** 245,260 **** (goto-char (point-min)) (insert (symbol-name (or charset 'us-ascii)) "''") (while (not (eobp)) ! (if (or (not (memq (following-char) ascii)) ! (memq (following-char) control) ! (memq (following-char) tspecial) ! (memq (following-char) special) ! (eq (following-char) ? )) (progn (when (>= (current-column) (1- limit)) (insert ";\n") (setq broken t)) ! (insert "%" (format "%02x" (following-char))) (delete-char 1)) (when (> (current-column) limit) (insert ";\n") --- 251,270 ---- (goto-char (point-min)) (insert (symbol-name (or charset 'us-ascii)) "''") (while (not (eobp)) ! (if (>= emacs-major-version 23) ! (setq following-char ! (multibyte-char-to-unibyte (following-char))) ! (setq following-char (following-char))) ! (if (or (not (memq following-char ascii)) ! (memq following-char control) ! (memq following-char tspecial) ! (memq following-char special) ! (eq following-char ? )) (progn (when (>= (current-column) (1- limit)) (insert ";\n") (setq broken t)) ! (insert "%" (format "%02x" following-char)) (delete-char 1)) (when (> (current-column) limit) (insert ";\n") -- Zhang Wei or Brep