From a04a74fec4b5e13e8464f1f3c9071fa0b56a13eb Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Wed, 12 Sep 2012 03:59:10 -0400 Subject: [PATCH] Improvements in building criteria string for IMAP SEARCH --- program/include/rcube_imap.php | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 66b5c4b..0b2f84d 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -1434,6 +1434,12 @@ $criteria = 'UNDELETED '.$criteria; } + // unset CHARSET if criteria string is ASCII, this way + // SEARCH won't be re-sent after "unsupported charset" response + if ($charset && $charset != 'US-ASCII' && is_ascii($criteria)) { + $charset = 'US-ASCII'; + } + if ($this->threading) { $threads = $this->conn->thread($folder, $this->threading, $criteria, true, $charset); @@ -1465,7 +1471,7 @@ } $messages = $this->conn->search($folder, - ($charset ? "CHARSET $charset " : '') . $criteria, true); + ($charset && $charset != 'US-ASCII' ? "CHARSET $charset " : '') . $criteria, true); // Error, try with US-ASCII (some servers may support only US-ASCII) if ($messages->is_error() && $charset && $charset != 'US-ASCII') { -- Gitblit v1.9.1