From 6ede93ebc8eaf6859ed5ffa36c582f8f816b707f Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Fri, 20 Nov 2009 12:35:31 +0000 Subject: [PATCH] fixing a problem regarding substr_count/mb_substr_count as they do not support the same number of parameters --- egw-pear/Net/IMAPProtocol.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/egw-pear/Net/IMAPProtocol.php b/egw-pear/Net/IMAPProtocol.php index 424dfd205b..0748a39de7 100644 --- a/egw-pear/Net/IMAPProtocol.php +++ b/egw-pear/Net/IMAPProtocol.php @@ -2363,8 +2363,14 @@ 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))) { - $numOfQuotes = substr_count($str,'"',$startingpos); - $numOfMaskedQuotes = substr_count($str,'\"',$startingpos); + $encoding =mb_internal_encoding(); + //if (mb_check_encoding($str)) { + // error_log(__METHOD__.' Encoding used:'.mb_internal_encoding().' Detected:'.mb_detect_encoding($str)); + // $encoding = mb_detect_encoding($str); + //} + // beware as mb_substr_count does not support the offset parameter. + $numOfQuotes = substr_count(substr($str,$startingpos),'"'); + $numOfMaskedQuotes = substr_count(substr($str,$startingpos),'\"'); 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");