From cb7f4e74d489265587ff2b941e9f8677ea6ca99b Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 26 Apr 2010 14:48:48 -0600 Subject: [PATCH] Charset specification is optional for SEARCH command --- framework/Imap_Client/lib/Horde/Imap/Client/Socket.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php index 2d955f81a..e57d2a4b1 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php @@ -1796,6 +1796,9 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base } } $cmd[] = $tmp; + + // Charset is mandatory for SORT (RFC 5256 [3]). + $cmd[] = $options['_query']['charset']; } else { // Check if the server supports ESEARCH (RFC 4731). $esearch = $this->queryCapability('ESEARCH'); @@ -1815,7 +1818,11 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base $cmd[] = $results; } - $cmd[] = 'CHARSET'; + // Charset is optional for SEARCH (RFC 3501 [6.4.4]). + if ($options['_query']['charset'] != 'US-ASCII') { + $cmd[] = 'CHARSET'; + $cmd[] = $options['_query']['charset']; + } // SEARCHRES requires ESEARCH unset($this->_temp['searchnotsaved']); @@ -1825,7 +1832,6 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base $sr = &$this->_temp['searchresp']; $er = $sr = array(); - $cmd[] = $options['_query']['charset']; $cmd = array_merge($cmd, $options['_query']['query']); $this->_sendLine($cmd); -- 2.11.0