* mm-util.el (mm-charset-to-coding-system): Add allow-override.
authorReiner Steib <Reiner.Steib@gmx.de>
Thu, 13 Oct 2005 16:36:20 +0000 (16:36 +0000)
committerReiner Steib <Reiner.Steib@gmx.de>
Thu, 13 Oct 2005 16:36:20 +0000 (16:36 +0000)
Use `mm-charset-override-alist' only when decoding.

* mm-bodies.el (mm-decode-body): Call
`mm-charset-to-coding-system' with allow-override argument.

lisp/ChangeLog
lisp/mm-bodies.el
lisp/mm-util.el

index 0d6ca6b..832e30e 100644 (file)
@@ -1,5 +1,11 @@
 2005-10-13  Reiner Steib  <Reiner.Steib@gmx.de>
 
+       * mm-util.el (mm-charset-to-coding-system): Add allow-override.
+       Use `mm-charset-override-alist' only when decoding.
+
+       * mm-bodies.el (mm-decode-body): Call
+       `mm-charset-to-coding-system' with allow-override argument.
+
        * gnus-art.el (gnus-mime-view-part-as-type-internal): Try to fetch
        `filename' from Content-Disposition if Content-Type doesn't
        provide `name'.
index 102d5e9..4a65e8d 100644 (file)
@@ -247,7 +247,10 @@ decoding.  If it is nil, default to `mail-parse-charset'."
     (when encoding
       (mm-decode-content-transfer-encoding encoding type))
     (when (featurep 'mule)  ; Fixme: Wrong test for unibyte session.
-      (let ((coding-system (mm-charset-to-coding-system charset)))
+      (let ((coding-system (mm-charset-to-coding-system
+                           ;; Allow overwrite using
+                           ;; `mm-charset-override-alist'.
+                           charset nil t)))
        (if (and (not coding-system)
                 (listp mail-parse-ignored-charsets)
                 (memq 'gnus-unknown mail-parse-ignored-charsets))
index 6999e73..ef2cca2 100644 (file)
@@ -488,11 +488,17 @@ mail with multiple parts is preferred to sending a Unicode one.")
        (pop alist))
       out)))
 
-(defun mm-charset-to-coding-system (charset &optional lbt)
+(defun mm-charset-to-coding-system (charset &optional lbt
+                                           allow-override)
   "Return coding-system corresponding to CHARSET.
 CHARSET is a symbol naming a MIME charset.
 If optional argument LBT (`unix', `dos' or `mac') is specified, it is
-used as the line break code type of the coding system."
+used as the line break code type of the coding system.
+
+If ALLOW-OVERRIDE is given, use `mm-charset-override-alist' to
+map undesired charset names to their replacement.  This should
+only be used for decoding, not for encoding."
+  ;; OVERRIDE is used (only) in `mm-decode-body'.
   (when (stringp charset)
     (setq charset (intern (downcase charset))))
   (when lbt
@@ -504,9 +510,11 @@ used as the line break code type of the coding system."
    ((or (null (mm-get-coding-system-list))
        (not (fboundp 'coding-system-get)))
     charset)
-   ;; Check override list quite early:
-   ((let ((cs (cdr (assq charset mm-charset-override-alist))))
-      (and cs (mm-coding-system-p cs) cs)))
+   ;; Check override list quite early.  Should only used for decoding, not for
+   ;; encoding!
+   ((and allow-override
+        (let ((cs (cdr (assq charset mm-charset-override-alist))))
+          (and cs (mm-coding-system-p cs) cs))))
    ;; ascii
    ((eq charset 'us-ascii)
     'ascii)