summaryrefslogtreecommitdiff
path: root/program/include/rcube_imap.inc
diff options
context:
space:
mode:
Diffstat (limited to 'program/include/rcube_imap.inc')
-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);