From c39b2e4de192800389b31ade99b9e35abbf5e242 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Thu, 30 Jul 2009 12:52:59 +0000 Subject: [PATCH] tackle problems with )( in Filenames --- egw-pear/Net/IMAPProtocol.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/egw-pear/Net/IMAPProtocol.php b/egw-pear/Net/IMAPProtocol.php index 6fcb7a2ba5..fee48fe54c 100644 --- a/egw-pear/Net/IMAPProtocol.php +++ b/egw-pear/Net/IMAPProtocol.php @@ -2362,8 +2362,15 @@ class Net_IMAPProtocol { if ($str[$pos] === $startDelim) $delimCount++; if ($str[$pos] === $stopDelim) $delimCount--; if ($str[$pos] === $stopDelim && ($str[$pos+1] === $startDelim || ($str[$pos+1] === $stopDelim && $delimCount<=0))) { - $pos--; // stopDelimited need to be parsed outside! - return false; + $numOfQuotes = substr_count($str,'"'); + $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) $pos++;