Make sure we run IMAP search queries in the proper charset
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 26 Apr 2010 21:32:31 +0000 (15:32 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 26 Apr 2010 21:33:25 +0000 (15:33 -0600)
imp/lib/Search.php

index 8d86836..001185f 100644 (file)
@@ -340,7 +340,14 @@ class IMP_Search
             }
         }
 
-        return $GLOBALS['imp_imap']->ob()->search($mailbox, $query, $opts);
+        /* Make sure we search in the proper charset. */
+        $new_query = clone $query;
+        $imap_charset = $GLOBALS['imp_imap']->ob()->validSearchCharset('UTF-8')
+            ? 'UTF-8'
+            : 'US-ASCII';
+        $new_query->charset($imap_charset, array('Horde_String', 'convertCharset'));
+
+        return $GLOBALS['imp_imap']->ob()->search($mailbox, $new_query, $opts);
     }
 
     /**