fix for identifying literals in mime_match_parentheses. cyrus sometimes
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 20 Jun 2002 12:37:12 +0000 (12:37 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 20 Jun 2002 12:37:12 +0000 (12:37 +0000)
returns literals instead of quoted strings. This fix solves mimedecode
errors if there exist " or ) or ( characters in literals.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2972 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/mime.php

index aafafe15618f5b4386492bc20f22494abdad83c5..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);
         }