mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-22 05:49:03 +01:00
improve the parsing of the raw data _advanceOverStr
This commit is contained in:
parent
fe3f2cb11c
commit
bb69cb6baf
@ -2307,7 +2307,7 @@ class Net_IMAPProtocol {
|
|||||||
// If inside of a string, skip string -- Boundary IDs and other
|
// If inside of a string, skip string -- Boundary IDs and other
|
||||||
// things can have ) in them.
|
// things can have ) in them.
|
||||||
if ( $str_line[$pos] != $startDelim ) {
|
if ( $str_line[$pos] != $startDelim ) {
|
||||||
$this->_prot_error("_getClosingParenthesisPos: must start with a '(' but is a '". $str_line[$pos] ."'!!!!\n" .
|
$this->_prot_error("_getClosingParenthesisPos: must start with a '".$startDelim."' but is a '". $str_line[$pos] ."'!!!!\n" .
|
||||||
"STR_LINE:$str_line|size:$len|POS: $pos\n" , __LINE__ , __FILE__ );
|
"STR_LINE:$str_line|size:$len|POS: $pos\n" , __LINE__ , __FILE__ );
|
||||||
return( $len );
|
return( $len );
|
||||||
}
|
}
|
||||||
@ -2350,6 +2350,7 @@ class Net_IMAPProtocol {
|
|||||||
function _advanceOverStr($str,&$pos,$len,$startDelim ='(', $stopDelim = ')' )
|
function _advanceOverStr($str,&$pos,$len,$startDelim ='(', $stopDelim = ')' )
|
||||||
{
|
{
|
||||||
#error_log(__METHOD__. $len . "#".$str."\n");
|
#error_log(__METHOD__. $len . "#".$str."\n");
|
||||||
|
$startingpos = $pos;
|
||||||
if ($str[$pos] !== '"') return false; // start condition failed
|
if ($str[$pos] !== '"') return false; // start condition failed
|
||||||
$pos++;
|
$pos++;
|
||||||
$delimCount=0;
|
$delimCount=0;
|
||||||
@ -2362,11 +2363,13 @@ class Net_IMAPProtocol {
|
|||||||
if ($str[$pos] === $startDelim) $delimCount++;
|
if ($str[$pos] === $startDelim) $delimCount++;
|
||||||
if ($str[$pos] === $stopDelim) $delimCount--;
|
if ($str[$pos] === $stopDelim) $delimCount--;
|
||||||
if ($str[$pos] === $stopDelim && ($str[$pos+1] === $startDelim || ($str[$pos+1] === $stopDelim && $delimCount<=0))) {
|
if ($str[$pos] === $stopDelim && ($str[$pos+1] === $startDelim || ($str[$pos+1] === $stopDelim && $delimCount<=0))) {
|
||||||
$numOfQuotes = substr_count($str,'"');
|
$numOfQuotes = substr_count($str,'"',$startingpos);
|
||||||
$numOfMaskedQuotes = substr_count($str,'\"');
|
$numOfMaskedQuotes = substr_count($str,'\"',$startingpos);
|
||||||
if ((($numOfQuotes - $numOfMaskedQuotes) % 2 ) == 0) {
|
if ((($numOfQuotes - $numOfMaskedQuotes) % 2 ) == 0) {
|
||||||
// quotes are balanced, so its unlikely that we meet a stop condition here as strings may contain )(
|
// quotes are balanced, so its unlikely that we meet a stop condition here as strings may contain )(
|
||||||
error_log(__METHOD__. "->Length: $len; NumOfQuotes: $numOfQuotes - NumofMaskedQuotes:$numOfMaskedQuotes #".$str."\n");
|
//error_log(__METHOD__. "->Length: $len; NumOfQuotes: $numOfQuotes - NumofMaskedQuotes:$numOfMaskedQuotes #".$str."\n");
|
||||||
|
error_log(__METHOD__." problem at $pos with:".$str[$pos]."(last character) Numberof delimiters ('".$startDelim."','".$stopDelim."') found:".$delimCount.' String:'.substr($str,$startingpos,$pos).' called from:'.function_backtrace());
|
||||||
|
//return false;
|
||||||
} else {
|
} else {
|
||||||
$pos--; // stopDelimited need to be parsed outside!
|
$pos--; // stopDelimited need to be parsed outside!
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user