From: stekkel Date: Thu, 20 Jun 2002 12:37:12 +0000 (+0000) Subject: fix for identifying literals in mime_match_parentheses. cyrus sometimes X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=ec41cfc7ff0a557b1edf4ee29929003944816fe1;ds=sidebyside 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. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2972 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/mime.php b/functions/mime.php index aafafe15..7a726a22 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -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); }