X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmime.php;h=ecbc6abcf217047c0cfd5e3986afa34e64b77222;hb=81a897dced6deb1e5fc9a332dfe572818f1da0f0;hp=e2cac35923136d5577e887e58a80567cbaac6957;hpb=1fd977808b077b015a79a92cad77f3c1e6894de4;p=squirrelmail.git
diff --git a/functions/mime.php b/functions/mime.php
index e2cac359..ecbc6abc 100644
--- a/functions/mime.php
+++ b/functions/mime.php
@@ -1,9 +1,12 @@
/** mime.php
**
- ** This contains the functions necessary to detect and decode MIME messages.
+ ** This contains the functions necessary to detect and decode MIME
+ ** messages.
+ **
**/
+ $mime_php = true;
if (!isset($i18n_php))
include "../functions/i18n.php";
@@ -11,7 +14,7 @@
/** This is the first function called. It decides if this is a multipart
message or if it should be handled as a single entity
**/
- function decodeMime($body, $bound, $type0, $type1, &$entities) {
+ function decodeMime($body, $bound, $type0, $type1, $encoding, $charset, &$entities) {
if ($type0 == "multipart") {
$bound = trim($bound);
$i = 0;
@@ -21,13 +24,15 @@
$p = 0;
/** Lets find the header for this entity **/
- /** If the first line after the boundary is blank, we use default values **/
+ /** If the first line after the boundary is blank, we
+ use default values **/
if (trim($body[$j]) == "") {
$ent_type0 = "text";
$ent_type1 = "plain";
$charset = "us-ascii";
$j++;
- /** If the first line ISNT blank, read in the header for this entity **/
+ /** If the first line ISNT blank, read in the header
+ for this entity **/
} else {
while ((substr(trim($body[$j]), 0, strlen("--$bound")) != "--$bound") && (trim($body[$j]) != "")) {
$entity_header[$p] = $body[$j];
@@ -39,7 +44,8 @@
}
- /** OK, we have the header information, now lets decide what to do with it **/
+ /** OK, we have the header information, now lets decide
+ what to do with it **/
if ($ent_type0 == "multipart") {
$y = 0;
while (substr($body[$j], 0, strlen("--$bound--")) != "--$bound--") {
@@ -47,7 +53,7 @@
$y++;
$j++;
}
- $ent = decodeMime($ent_body, $ent_bound, $ent_type0, $ent_type1, $entities);
+ $ent = decodeMime($ent_body, $ent_bound, $ent_type0, $ent_type1, $charset, $entities);
$entities = $ent;
} else {
$j++;
@@ -116,36 +122,43 @@
return false;
}
- /** This returns a parsed string called $body. That string can then be displayed
- as the actual message in the HTML. It contains everything needed, including
- HTML Tags, Attachments at the bottom, etc.
+ /** This returns a parsed string called $body. That string can then
+ be displayed as the actual message in the HTML. It contains
+ everything needed, including HTML Tags, Attachments at the
+ bottom, etc.
**/
function formatBody($message, $color, $wrap_at) {
- /** this if statement checks for the entity to show as the primary message. To
- add more of them, just put them in the order that is their priority.
+ /** this if statement checks for the entity to show as the
+ primary message. To add more of them, just put them in the
+ order that is their priority.
**/
$id = $message["INFO"]["ID"];
$urlmailbox = urlencode($message["INFO"]["MAILBOX"]);
if (containsType($message, "text", "html", $ent_num)) {
$body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
} else if (containsType($message, "text", "plain", $ent_num)) {
$body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
}
// 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"]);
+ $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
} else if (containsType($message, "message", "any_type", $ent_num)) {
$body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+ $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
}
}
- /** If there are other types that shouldn't be formatted, add them here **/
+ /** 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 = translateText($body, $wrap_at, $charset);
$body .= "
". _("Download this as a file") ."
";