X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmime.php;h=f61322bf1f30b9d2e6f91323bdf3334e11748e6b;hb=09c3f7f32dbfd8d850f350772334d798d639482b;hp=3403e0726866ee9f04b1d8300c86b832caf12acd;hpb=d3cdb279bd61b172926b51d41d09c8a691d6c347;p=squirrelmail.git diff --git a/functions/mime.php b/functions/mime.php index 3403e072..f61322bf 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -11,6 +11,7 @@ function decodeMime($body, $bound, $type0, $type1, &$entities) { if ($type0 == "multipart") { $bound = trim($bound); + $i = 0; while (($i < count($body)) && (substr($body[$i], 0, strlen("--$bound--")) != "--$bound--")) { if (trim($body[$i]) == "--$bound") { $j = $i+1; @@ -116,36 +117,33 @@ as the actual message in the HTML. It contains everything needed, including HTML Tags, Attachments at the bottom, etc. **/ - function formatBody($message, $color) { + 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. **/ $id = $message["INFO"]["ID"]; $urlmailbox = urlencode($message["INFO"]["MAILBOX"]); - $body = ""; if (containsType($message, "text", "html", $ent_num)) { - $body .= decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); + $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); } else if (containsType($message, "text", "plain", $ent_num)) { - $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body .= "" . nl2br(trim($tmpbody)) . ""; + $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); } // add other primary displaying message types here else { // find any type that's displayable if (containsType($message, "text", "any_type", $ent_num)) { - $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body .= "" . nl2br(trim($tmpbody)) . ""; + $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); } else if (containsType($message, "message", "any_type", $ent_num)) { - $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body .= "" . nl2br(trim($tmpbody)) . ""; + $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); } } /** If there are other types that shouldn't be formatted, add them here **/ if ($message["ENTITIES"][$ent_num]["TYPE1"] != "html") - $body = translateText($body); + $body = translateText($body, $wrap_at); + $body .= "
Download this as a file

"; @@ -191,12 +189,29 @@ $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; + $body_ary = explode("\n", $body); + + for ($q=0; $q < count($body_ary); $q++) { + if (substr(trim($body_ary[$q]), -1) == "=") { + $body_ary[$q] = trim($body_ary[$q]); + $body_ary[$q] = substr($body_ary[$q], 0, strlen($body_ary[$q])-1); + } else if (substr(trim($body_ary[$q]), -3) == "=20") { + $body_ary[$q] = trim($body_ary[$q]); + $body_ary[$q] = substr($body_ary[$q], 0, strlen($body_ary[$q])-3); + $body_ary[$q] = "$body_ary[$q]\n"; + } + } + + for ($q=0;$q < count($body_ary);$q++) { + $body_ary[$q] = ereg_replace("=3D", "=", $body_ary[$q]); + } + + $body = ""; + for ($i = 0; $i < count($body_ary); $i++) { + $body .= "$body_ary[$i]\n"; + } + $newbody = $body; } else if ($encoding == "base64") { $newbody = base64_decode($body);