summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-11-26 13:10:27 +0000
committeralecpl <alec@alec.pl>2011-11-26 13:10:27 +0000
commit3e5c709fa719e2458df06e515fa4893ae743edda (patch)
tree3029b2f6afa48b2c82ca249100eb9b00f99c0981 /program/steps/mail
parent6a6168619a2d538263eb99247b18154a72e5e298 (diff)
- Fix so TEXT key will remove all HEADER keys in IMAP SEARCH (#1488208)
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/search.inc20
1 files changed, 13 insertions, 7 deletions
diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc
index 2e7fd130c..593eac427 100644
--- a/program/steps/mail/search.inc
+++ b/program/steps/mail/search.inc
@@ -31,6 +31,7 @@ $str = get_input_value('_q', RCUBE_INPUT_GET, true);
$mbox = get_input_value('_mbox', RCUBE_INPUT_GET, true);
$filter = get_input_value('_filter', RCUBE_INPUT_GET);
$headers = get_input_value('_headers', RCUBE_INPUT_GET);
+$subject = array();
$search_request = md5($mbox.$filter.$str);
@@ -70,14 +71,19 @@ else if (preg_match("/^body:.*/i", $str))
list(,$srch) = explode(":", $str);
$subject['text'] = "TEXT";
}
-else if(trim($str))
+else if (strlen(trim($str)))
{
if ($headers) {
- foreach(explode(',', $headers) as $header)
- switch ($header) {
- case 'text': $subject['text'] = 'TEXT'; break;
- default: $subject[$header] = 'HEADER '.strtoupper($header);
+ foreach (explode(',', $headers) as $header) {
+ if ($header == 'text') {
+ // #1488208: get rid of other headers when searching by "TEXT"
+ $subject = array('text' => 'TEXT');
+ break;
}
+ else {
+ $subject[$header] = 'HEADER '.strtoupper($header);
+ }
+ }
// save search modifiers for the current folder to user prefs
$search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT);
@@ -89,9 +95,9 @@ else if(trim($str))
}
}
-$search = $srch ? trim($srch) : trim($str);
+$search = isset($srch) ? trim($srch) : trim($str);
-if ($subject) {
+if (!empty($subject)) {
$search_str .= str_repeat(' OR', count($subject)-1);
foreach ($subject as $sub)
$search_str .= sprintf(" %s {%d}\r\n%s", $sub, strlen($search), $search);