Selaa lähdekoodia

fix for identifying literals in mime_match_parentheses. cyrus sometimes
returns literals instead of quoted strings. This fix solves mimedecode
errors if there exist " or ) or ( characters in literals.

stekkel 23 vuotta sitten
vanhempi
commit
0a5c3280f5
1 muutettua tiedostoa jossa 13 lisäystä ja 4 poistoa
  1. 13 4
      functions/mime.php

+ 13 - 4
functions/mime.php

@@ -411,9 +411,12 @@ function mime_match_parenthesis ($pos, $structure) {
 
 
     $j = strlen( $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} != '(' ) {
     if ( $structure{$pos} != '(' ) {
         return( $j );
         return( $j );
     }
     }
@@ -422,7 +425,7 @@ function mime_match_parenthesis ($pos, $structure) {
         $pos++;
         $pos++;
         if ($structure{$pos} == ')') {
         if ($structure{$pos} == ')') {
             return $pos;
             return $pos;
-        } elseif ($structure{$pos} == '"') {
+        } elseif ($structure{$pos} == '"') { /* check for quoted string */
             $pos++;
             $pos++;
             while ( $structure{$pos} != '"' &&
             while ( $structure{$pos} != '"' &&
                     $pos < $j ) {
                     $pos < $j ) {
@@ -433,6 +436,12 @@ function mime_match_parenthesis ($pos, $structure) {
                }
                }
                $pos++;
                $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} == '(' ) {
         } elseif ( $structure{$pos} == '(' ) {
             $pos = mime_match_parenthesis ($pos, $structure);
             $pos = mime_match_parenthesis ($pos, $structure);
         }
         }