Browse Source

Charset and encoding support is now working again :-)

gustavf 25 years ago
parent
commit
d6ec0350d6
2 changed files with 9 additions and 1 deletions
  1. 4 0
      functions/i18n.php
  2. 5 1
      functions/mime.php

+ 4 - 0
functions/i18n.php

@@ -26,11 +26,15 @@
 
    // Decodes a string to the internal encoding from the given charset
    function charset_decode ($charset, $string) {
+      global $debug_mime;
+
       // All HTML special characters are 7 bit and can be replaced first
       $string = htmlspecialchars ($string);
 
       $charset = strtolower($charset);
 
+      if ($debug_mime) $string = $charset.":".$string;
+
       if (ereg("iso-8859-(.*)", $charset, $res)) {
          if ($res[1] == "1")
             return charset_decode_iso_8859_1 ($string);

+ 5 - 1
functions/mime.php

@@ -26,7 +26,7 @@
       var $type0, $type1, $boundary, $charset, $encoding;
       var $to, $from, $date, $cc, $bcc, $reply_to, $subject;
       var $id, $mailbox, $description;
-      var $entity_id, $message_id;
+      var $entity_id, $message_id, $charset;
    }
    
    class message {
@@ -255,6 +255,7 @@
             if ($debug_mime) echo "<tt>".$properties[$i]["name"]." = " . $properties[$i]["value"] . "</tt><br>";
          }
       }
+
       return $msg;
    }
 
@@ -426,7 +427,10 @@
       $id = $message->header->id;
       $urlmailbox = urlencode($message->header->mailbox);
 
+      // Get the right entity and redefine message to be this entity
       $ent_num = findDisplayEntity ($message);
+      $message = getEntity($message, $ent_num);
+
       $body = mime_fetch_body ($imap_stream, $id, $ent_num); 
       $body = decodeBody($body, $message->header->encoding);