fix for identifying literals in mime_match_parentheses. cyrus sometimes
[squirrelmail.git] / functions / mime.php
index 33b829c40218473d2f66e336cd95090333031e7a..7a726a2217ba99861eb1211ac08fc650124f6f8a 100644 (file)
@@ -411,9 +411,12 @@ function mime_match_parenthesis ($pos, $structure) {
 
     $j = strlen( $structure );
     
-    // ignore all extra characters
-    // If inside of a string, skip string -- Boundary IDs and other
-    // things can have ) in them.
+    /*
+     * ignore all extra characters
+     * If inside of a quoted string or literal, skip it -- Boundary IDs and other
+     * things can have ) in them.
+     */
+     
     if ( $structure{$pos} != '(' ) {
         return( $j );
     }
@@ -422,7 +425,7 @@ function mime_match_parenthesis ($pos, $structure) {
         $pos++;
         if ($structure{$pos} == ')') {
             return $pos;
-        } elseif ($structure{$pos} == '"') {
+        } elseif ($structure{$pos} == '"') { /* check for quoted string */
             $pos++;
             while ( $structure{$pos} != '"' &&
                     $pos < $j ) {
@@ -433,6 +436,12 @@ function mime_match_parenthesis ($pos, $structure) {
                }
                $pos++;
             }
+       } elseif ($structure{$pos} == '{') { /* check for literal */ 
+           $str = substr($structure, $pos);
+           $pos++;
+           if (preg_match("/^\{(\d+)\}.*/",$str,$reg)) {
+               $pos = $pos + strlen($reg[1]) + $reg[1] + 2;
+           } 
         } elseif ( $structure{$pos} == '(' ) {
             $pos = mime_match_parenthesis ($pos, $structure);
         }
@@ -2061,8 +2070,8 @@ function magicHTML($body, $id, $message){
                           Array(
                                 "|^([\'\"])\s*\.\./.*([\'\"])|si",
                                 "/^([\'\"])\s*\S+script\s*:.*([\'\"])/si",
-                               "/^([\'\"])\s*mocha\s*:*(.*)([\'\"])/si",
-                               "/^([\'\"])\s*about\s*:(.*)([\'\"])/si"
+                               "/^([\'\"])\s*mocha\s*:*.*([\'\"])/si",
+                               "/^([\'\"])\s*about\s*:.*([\'\"])/si"
                                 ),
                           Array(
                                 "\\1$secremoveimg\\2",