From 2b4bae16a988099279b86378d05eeff6666a9423 Mon Sep 17 00:00:00 2001 From: alecpl Date: Wed, 8 Oct 2008 13:26:42 +0000 Subject: - Fix imap searching on ISMail (#1485466) --- program/lib/imap.inc | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'program') diff --git a/program/lib/imap.inc b/program/lib/imap.inc index 7c257de97..98173687b 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -66,6 +66,7 @@ optional resposne in iil_Connect(), added iil_C_GetCapability() - remove 'undisclosed-recipients' string from 'To' header - iil_C_HandlePartBody(): added 6th argument and fixed endless loop + - added iil_PutLineC() ********************************************************/ @@ -189,8 +190,28 @@ function iil_xor($string, $string2) { } function iil_PutLine($fp, $string, $endln=true) { -// console('C: '. $string); - return fputs($fp, $string . ($endln ? "\r\n" : '')); +// console('C: '. rtrim($string)); + return fputs($fp, $string . ($endln ? "\r\n" : '')); +} + +// iil_PutLine replacement with Command Continuation Requests (RFC3501 7.5) support +function iil_PutLineC($fp, $string, $endln=true) { + if ($endln) + $string .= "\r\n"; + + $res = 0; + if ($parts = preg_split('/(\{[0-9]+\}\r\n)/m', $string, -1, PREG_SPLIT_DELIM_CAPTURE)) { + for($i=0, $cnt=count($parts); $i<$cnt; $i++) { + if(preg_match('/^\{[0-9]+\}\r\n$/', $parts[$i+1])) { + $res += iil_PutLine($fp, $parts[$i].$parts[$i+1], false); + $line = iil_ReadLine($fp, 1000); + $i++; + } + else + $res += iil_PutLine($fp, $parts[$i], false); + } + } + return $res; } function iil_ReadLine($fp, $size) { @@ -2062,7 +2083,7 @@ function iil_C_Search(&$conn, $folder, $criteria) { $c = 0; $query = 'srch1 SEARCH ' . chop($criteria); - iil_PutLine($fp, $query); + iil_PutLineC($fp, $query); do { $line=trim(iil_ReadLine($fp, 10000)); if (eregi("^\* SEARCH", $line)) { -- cgit v1.2.3