[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnus doesn't encode non-ascii attachment filenames
From: |
Zhang Wei |
Subject: |
Re: gnus doesn't encode non-ascii attachment filenames |
Date: |
Tue, 14 Feb 2006 09:25:59 +0800 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/23.0.0 (gnu/linux) |
"Richard M. Stallman" <address@hidden> 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
<address@hidden>