tackle problems with )( in Filenames

This commit is contained in:
Klaus Leithoff 2009-07-30 12:52:59 +00:00
parent 18f2db2fc8
commit c39b2e4de1

View File

@ -2362,8 +2362,15 @@ 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))) {
$pos--; // stopDelimited need to be parsed outside! $numOfQuotes = substr_count($str,'"');
return false; $numOfMaskedQuotes = substr_count($str,'\"');
if ((($numOfQuotes - $numOfMaskedQuotes) % 2 ) == 0) {
// 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");
} else {
$pos--; // stopDelimited need to be parsed outside!
return false;
}
} }
if ($str[$pos] === '\\') $pos++; // all escaped chars are overread (eg. \\, \", \x) if ($str[$pos] === '\\') $pos++; // all escaped chars are overread (eg. \\, \", \x)
$pos++; $pos++;