X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmime.php;h=cc00e3c771f94d582e139a6055ce9d77b74cd053;hb=db87f79ca460cafaeac69f613f49f6472fae6da6;hp=f81d08f07efb21981ff5044b810f0c3ee22084a3;hpb=78509c544d86d8e4260ec93faed8d2a17362082b;p=squirrelmail.git diff --git a/functions/mime.php b/functions/mime.php index f81d08f0..cc00e3c7 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -116,8 +116,7 @@ as the actual message in the HTML. It contains everything needed, including HTML Tags, Attachments at the bottom, etc. **/ - function formatBody($message) { - include ("../config/config.php"); + function formatBody($message, $color) { /** 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. @@ -130,17 +129,17 @@ $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($tmpbody) . ""; + $body .= "" . nl2br(trim($tmpbody)) . ""; } // 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($tmpbody) . ""; + $body .= "" . nl2br(trim($tmpbody)) . ""; } else if (containsType($message, "message", "any_type", $ent_num)) { $tmpbody = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]); - $body .= "" . nl2br($tmpbody) . ""; + $body .= "" . nl2br(trim($tmpbody)) . ""; } } @@ -192,12 +191,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);