parsing $message to magicHTML for better handling message/rfc822 attachments
[squirrelmail.git] / functions / mime.php
index 7bbfa3741d32a3b4460d3e287e40fe11077597cd..23fa3ce1146bf2f7f9d2afd829906aa93cff7ef8 100644 (file)
@@ -229,6 +229,21 @@ function mime_get_element (&$structure, $msg, $ent_id) {
            $pos++;
         }
         $structure = substr($structure, strlen($text) + 2);
+     } else if ($char == '{') {
+         /**
+          * loop through until we find the matching quote, 
+          * and return that as a string
+          */
+         $pos = 1;
+         $len = '';
+         while (($char = $structure{$pos}) != '}' 
+                && $pos < strlen($structure)) {
+             $len .= $char;
+             $pos++;
+         }
+         $structure = substr($structure, strlen($len) + 4);
+         $text = substr($structure, 0, $len);
+         $structure = substr($structure, $len + 1);
      } else if ($char == '(') {
         // comment me
         $end = mime_match_parenthesis (0, $structure);
@@ -779,7 +794,7 @@ function formatBody($imap_stream, $message, $color, $wrap_at) {
                 $body = strip_tags( $body );
                 translateText($body, $wrap_at, $body_message->header->charset);
             } else {
-                $body = MagicHTML( $body, $id );
+                $body = MagicHTML( $body, $id, $message );
             }
         } else {
             translateText($body, $wrap_at, $body_message->header->charset);
@@ -996,7 +1011,8 @@ function decodeBody($body, $encoding) {
 
   global $show_html_default;
 
-  if ($encoding == 'quoted-printable') {
+  if ($encoding == 'quoted-printable' ||
+      $encoding == 'quoted_printable') {
      $body = quoted_printable_decode($body);
 
 
@@ -1426,7 +1442,7 @@ function sq_getnxtag($body, $offset){
                 $pos++;
                 $tagtype = 3;
             } else {
-                $gt = getnxstr($body, $pos, ">");
+                $gt = sq_findnxstr($body, $pos, ">");
                 $retary = Array(false, false, false, $lt, $gt);
                 return $retary;
             }
@@ -1926,7 +1942,7 @@ function sq_sanitize($body,
  * @param  $id    the id of the message
  * @return        a string with html safe to display in the browser.
  */
-function magicHTML($body, $id){
+function magicHTML($body, $id, $message){
     global $attachment_common_show_images, $view_unsafe_images,
         $has_unsafe_images, $message;
     /**