[dev] [framework-patch] setting the charset (html attachments)

Francois Marier francois at nit.ca
Tue Aug 3 19:05:44 PDT 2004


Here's a patch that sets the charset correctly for HTML attachments.

The two problems I found:

1- the charset was quoted with double quotes (e.g. charset="koi8-r"
instead of charset=koi8-r) which prevented Mozilla from reading it
properly.

2- the charset was set twice when setting the type (e.g. "text/html;
charset=koi8-r; charset=koi8-r")

Francois
-------------- next part --------------
diff -rpuN -X ../ignorelist ../build/framework/MIME/MIME/Contents.php framework/MIME/MIME/Contents.php
--- ../build/framework/MIME/MIME/Contents.php	Tue Jun 29 07:32:14 2004
+++ framework/MIME/MIME/Contents.php	Tue Aug  3 21:39:11 2004
@@ -452,12 +452,7 @@ class MIME_Contents {
     function getMIMEViewerType(&$mime_part)
     {
         if (($viewer = &$this->getMIMEViewer($mime_part))) {
-            $type = $viewer->getType();
-            $charset = $mime_part->getCharset(true);
-            if ($charset) {
-                $type .= '; charset=' . $charset;
-            }
-            return $type;
+            return $viewer->getType();
         } else {
             return false;
         }
diff -rpuN -X ../ignorelist ../build/framework/MIME/MIME/Part.php framework/MIME/MIME/Part.php
--- ../build/framework/MIME/MIME/Part.php	Wed Jun 23 15:43:28 2004
+++ framework/MIME/MIME/Part.php	Tue Aug  3 21:39:34 2004
@@ -452,7 +452,7 @@ class MIME_Part {
          $ptype = $this->getPrimaryType();
          $type = $ptype . '/' . $this->getSubType();
          if ($charset && ($ptype == 'text')) {
-             $type .= '; ' . 'charset="' . $this->getCharset() . '"';
+             $type .= '; charset=' . $this->getCharset();
          }
          return $type;
      }


More information about the dev mailing list