X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmime.php;h=8b364a37ea2e949addcbc07caa7eda70d161ee29;hb=01f519fd563edf7c1bc6f72e3229e10780de3fc4;hp=d6e98d8561f2d8e8205c4ccdfdc56bb2b5ff8cec;hpb=7831268eb119a34cd370a5e9d7502052f033880b;p=squirrelmail.git diff --git a/functions/mime.php b/functions/mime.php index d6e98d85..8b364a37 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -1,29 +1,38 @@ " . nl2br($body) . ""; } // add other primary displaying message types here else { // find any type that's displayable if (containsType($message, "text", "any_type", $ent_num)) { $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body = "" . nl2br($body) . ""; } else if (containsType($message, "message", "any_type", $ent_num)) { $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body = "" . nl2br($body) . ""; } } - $body .= "
"; + /** If there are other types that shouldn't be formatted, add + them here **/ + if ($message["ENTITIES"][$ent_num]["TYPE1"] != "html") + $body = translateText($body, $wrap_at); + + + $body .= "
". _("Download this as a file") ."

"; /** Display the ATTACHMENTS: message if there's more than one part **/ if (count($message["ENTITIES"]) > 1) { @@ -160,8 +177,7 @@ $num++; $filename = $message["ENTITIES"][$i]["FILENAME"]; if (trim($filename) == "") { - $filename = "UNKNOWN_FORMAT_" . time() . $i; - $display_filename = "Attachment $i"; + $display_filename = "untitled$i"; } else { $display_filename = $filename; } @@ -181,22 +197,41 @@ function decodeBody($body, $encoding) { $encoding = strtolower($encoding); - if ($encoding == "us-ascii") { - $newbody = $body; // if only they all were this easy - - } else if ($encoding == "quoted-printable") { - echo "$body"; - $body = ereg_replace("=3D", "=", $body); - $body = ereg_replace("=\n", "", $body); - $body = ereg_replace("=20", "\n", $body); - $newbody= $body; + if ($encoding == "quoted-printable") { + $body = quoted_printable_decode($body); + while (ereg("=\n", $body)) + $body = ereg_replace ("=\n", "", $body); } else if ($encoding == "base64") { - $newbody = base64_decode($body); - - } else { - $newbody = $body; + $body = base64_decode($body); } - return $newbody; + + // All other encodings are returned raw. + return $body; } -?> \ No newline at end of file + + + // This functions decode strings that is encoded according to + // RFC1522 (MIME Part Two: Message Header Extensions for Non-ASCII Text). + function decodeHeader ($string) { + if (eregi('=\?([^?]+)\?(q|b)\?([^?]+)\?=', + $string, $res)) { + if (ucfirst($res[2]) == "B") { + $replace = base64_decode($res[3]); + } else { + $replace = ereg_replace("_", " ", $res[3]); + $replace = quoted_printable_decode($replace); + } + + $replace = charset_decode ($res[1], $replace); + + $string = eregi_replace + ('=\?([^?]+)\?(q|b)\?([^?]+)\?=', + $replace, $string); + // In case there should be more encoding in the string: recurse + return (decodeHeader($string)); + } else + return ($string); + } + +?>