From 5d79e9f0846bb2cb51d72dcf842e9ba8021e9217 Mon Sep 17 00:00:00 2001 From: Thomas Abthorpe Date: Mon, 4 Jan 2010 21:12:48 +0000 Subject: - Really fix IMAP search - Bump PORTREVISION PR: ports/141736 Submitted by: Yuri Pankov --- .../files/patch-functions__imap_search.php | 62 +++++++++++----------- 1 file changed, 30 insertions(+), 32 deletions(-) (limited to 'mail/squirrelmail/files') diff --git a/mail/squirrelmail/files/patch-functions__imap_search.php b/mail/squirrelmail/files/patch-functions__imap_search.php index 1f1ca53b053d..2bd94460d74d 100644 --- a/mail/squirrelmail/files/patch-functions__imap_search.php +++ b/mail/squirrelmail/files/patch-functions__imap_search.php @@ -1,9 +1,26 @@ ---- ./functions/imap_search.php.orig 2009-11-09 11:29:39.000000000 -0500 -+++ ./functions/imap_search.php 2009-11-09 11:38:35.000000000 -0500 -@@ -46,22 +46,23 @@ - on the client side, but should be fixed on the server - as per the RFC */ +--- functions/imap_search.php 2009/07/29 02:21:06 13800 ++++ functions/imap_search.php 2009/12/14 21:18:29 13877 +@@ -5,7 +5,7 @@ + * + * IMAP search routines + * +- * @copyright © 1999-2009 The SquirrelMail Project Team ++ * @copyright 1999-2009 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package squirrelmail +@@ -38,30 +38,17 @@ + $multi_search = explode(' ', $search_what); + $search_string = ''; +- /* it seems macosx and hmailserver do not support the prefered search +- syntax so we fall back to the older style. This IMAP +- server has a problem with multiple search terms. Instead +- of returning the messages that match all the terms it +- returns the messages that match each term. Could be fixed +- on the client side, but should be fixed on the server +- as per the RFC */ +- - if ($imap_server_type == 'macosx' || $imap_server_type == 'hmailserver') { - foreach ($multi_search as $multi_search_part) { - if (strtoupper($languages[$squirrelmail_language]['CHARSET']) == 'ISO-2022-JP') { @@ -15,13 +32,7 @@ + $multi_search[$idx] = mb_convert_encoding($search_parth, 'JIS', 'auto'); } } -+ -+ $search_lit = array(); -+ -+ if ($imap_server_type == 'macosx' || $imap_server_type == 'hmailserver') { -+ $search_string .= $search_where . ' ' . implode(' ', $multi_search); -+ } - else { +- else { - foreach ($multi_search as $multi_search_part) { - if (strtoupper($languages[$squirrelmail_language]['CHARSET']) == 'ISO-2022-JP') { - $multi_search_part = mb_convert_encoding($multi_search_part, 'JIS', 'auto'); @@ -29,29 +40,16 @@ - $search_string .= $search_where . ' {' . strlen($multi_search_part) - . "}\r\n" . $multi_search_part . ' '; - } -+ $search_string .= $search_where; -+ $search_lit = array( -+ 'command' => '', -+ 'literal_args' => $multi_search -+ ); ++ ++ foreach ($multi_search as $string) { ++ $search_string .= $search_where ++ . ' "' ++ . str_replace(array('\\', '"'), array('\\\\', '\\"'), $string) ++ . '" '; } $search_string = trim($search_string); -@@ -76,15 +77,24 @@ - $ss = "SEARCH ALL $search_string"; - } - -- /* read data back from IMAP */ -- $readin = sqimap_run_command($imapConnection, $ss, false, $result, $message, $uid_support); -+ if (empty($search_lit)) { -+ /* read data back from IMAP */ -+ $readin = sqimap_run_command($imapConnection, $ss, false, $result, $message, $uid_support); -+ } else { -+ $search_lit['command'] = $ss; -+ $readin = sqimap_run_literal_command($imapConnection, $search_lit, false, $result, $message, $uid_support); -+ } - - /* try US-ASCII charset if search fails */ +@@ -83,8 +70,12 @@ if (isset($languages[$squirrelmail_language]['CHARSET']) && strtolower($result) == 'no') { $ss = "SEARCH CHARSET \"US-ASCII\" ALL $search_string"; -- cgit v1.2.3