unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Zhang Wei <id.brep@gmail.com>
Cc: handa@m17n.org, emacs-devel@gnu.org
Subject: Re: gnus doesn't encode non-ascii attachment filenames
Date: Tue, 14 Feb 2006 09:25:59 +0800	[thread overview]
Message-ID: <87irriras8.fsf@emacsfans.org> (raw)
In-Reply-To: <E1F8oEg-0007Q6-Vf@fencepost.gnu.org> (Richard M. Stallman's message of "Mon, 13 Feb 2006 19:40:06 -0500")

"Richard M. Stallman" <rms@gnu.org> 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
<brep@smth.org>

  parent reply	other threads:[~2006-02-14  1:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-13  7:00 gnus doesn't encode non-ascii attachment filenames Zhang Wei
     [not found] ` <E1F8oEg-0007Q6-Vf@fencepost.gnu.org>
2006-02-14  1:25   ` Zhang Wei [this message]
2006-02-14  2:13     ` Kenichi Handa
2006-02-14  3:36       ` Miles Bader
2006-02-14 10:59         ` Gnus compatibility with Emacs 23 (unicode branch) (was: gnus doesn't encode non-ascii attachment filenames) Reiner Steib
2006-02-23 21:03           ` Gnus compatibility with Emacs 23 (unicode branch) Reiner Steib
2006-03-23  5:58         ` gnus doesn't encode non-ascii attachment filenames Kenichi Handa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87irriras8.fsf@emacsfans.org \
    --to=id.brep@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=handa@m17n.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).