summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2006-08-04 13:56:08 +0000
committerthomascube <thomas@roundcube.net>2006-08-04 13:56:08 +0000
commit42000a5d64ef92d3b85c71381654f3f8f6cb9cfd (patch)
tree4b9d421c4f09910127104e6e8b5c88f3ff1f0b42 /program/include
parentfa4cd20fb14c087c80e6a9cde11df17d46e07566 (diff)
Added correct charset support for message searching
Diffstat (limited to 'program/include')
-rw-r--r--program/include/rcube_imap.inc12
1 files changed, 9 insertions, 3 deletions
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index be89bd6b1..7f74eb7d9 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -827,13 +827,19 @@ class rcube_imap
* @return array search results as list of message ids
* @access public
*/
- function search($mbox_name='', $criteria='ALL', $str=NULL)
+ function search($mbox_name='', $criteria='ALL', $str=NULL, $charset=NULL)
{
$mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox;
if ($str && $criteria)
{
- $criteria = 'CHARSET UTF-8 '.$criteria.' "'.UTF7EncodeString($str).'"';
- return $this->_search_index($mailbox, $criteria);
+ $search = (!empty($charset) ? "CHARSET $charset " : '') . sprintf("%s {%d}\r\n%s", $criteria, strlen($str), $str);
+ $results = $this->_search_index($mailbox, $search);
+
+ // try search without charset (probably not supported by server)
+ if (empty($results))
+ $results = $this->_search_index($mailbox, "$criteria $str");
+
+ return $results;
}
else
return $this->_search_index($mailbox, $criteria);