Changeset 42000a5 in github


Ignore:
Timestamp:
Aug 4, 2006 9:56:08 AM (7 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
9a52614
Parents:
fa4cd20
Message:

Added correct charset support for message searching

Location:
program
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_imap.inc

    rfa4cd20 r42000a5  
    828828   * @access public 
    829829   */ 
    830   function search($mbox_name='', $criteria='ALL', $str=NULL) 
     830  function search($mbox_name='', $criteria='ALL', $str=NULL, $charset=NULL) 
    831831    { 
    832832    $mailbox = $mbox_name ? $this->_mod_mailbox($mbox_name) : $this->mailbox; 
    833833    if ($str && $criteria) 
    834834      { 
    835       $criteria = 'CHARSET UTF-8 '.$criteria.' "'.UTF7EncodeString($str).'"'; 
    836       return $this->_search_index($mailbox, $criteria); 
     835      $search = (!empty($charset) ? "CHARSET $charset " : '') . sprintf("%s {%d}\r\n%s", $criteria, strlen($str), $str); 
     836      $results = $this->_search_index($mailbox, $search); 
     837 
     838      // try search without charset (probably not supported by server) 
     839      if (empty($results)) 
     840        $results = $this->_search_index($mailbox, "$criteria $str"); 
     841       
     842      return $results; 
    837843      } 
    838844    else 
  • program/steps/mail/search.inc

    rac6b87c r42000a5  
    99 +-----------------------------------------------------------------------+ 
    1010 | Author: Benjamin Smith <defitro@gmail.com>                            | 
     11 |         Thomas Bruederli <roundcube@gmail.com>                        | 
    1112 +-----------------------------------------------------------------------+ 
    1213 
     
    1920$_SESSION['page'] = 1; 
    2021 
     22// search query comes in with ISO encoding because javascript escape() 
     23// uses ISO-8859-1. Better handling for that will follow. 
     24$imap_charset = 'ISO-8859-1'; 
     25 
    2126// get search string 
    2227$str = get_input_value('_search', RCUBE_INPUT_GET); 
     
    2833if (preg_match("/^from:/i", $str)) { 
    2934  list(,$srch) = explode(":", $str); 
    30   $search = $IMAP->search($mbox, "FROM" ,trim($srch)); 
     35  $search = $IMAP->search($mbox, "HEADER FROM" ,trim($srch), $imap_charset); 
    3136  finish_search($mbox, $search); 
    3237} 
    3338else if (preg_match("/^to:/i", $str)) { 
    3439  list(,$srch) = explode(":", $str); 
    35   $search = $IMAP->search($mbox, "TO", trim($srch)); 
     40  $search = $IMAP->search($mbox, "HEADER TO", trim($srch), $imap_charset); 
    3641  finish_search($mbox, $search); 
    3742} 
    3843else if (preg_match("/^cc:/i", $str)) { 
    3944  list(,$srch) = explode(":", $str); 
    40   $search = $IMAP->search($mbox, "CC", trim($srch)); 
     45  $search = $IMAP->search($mbox, "HEADER CC", trim($srch), $imap_charset); 
    4146  finish_search($mbox, $search); 
    4247} 
    4348else if (preg_match("/^subject:/i", $str)) { 
    4449  list(,$srch) = explode(":", $str); 
    45   $search = $IMAP->search($mbox, "SUBJECT", trim($srch)); 
     50  $search = $IMAP->search($mbox, "HEADER SUBJECT", trim($srch), $imap_charset); 
    4651  finish_search($mbox, $search); 
    4752} 
    4853else if (preg_match("/^body:/i", $str)) { 
    4954  list(,$srch) = explode(":", $str); 
    50   $search = $IMAP->search($mbox, "TEXT", trim($srch)); 
     55  $search = $IMAP->search($mbox, "TEXT", trim($srch), $imap_charset); 
    5156  finish_search($mbox, $search); 
    5257} 
    5358// search in subject and sender by default 
    5459else { 
    55   $search = $IMAP->search($mbox, "SUBJECT", trim($str)); 
    56   $search2 = $IMAP->search($mbox, "FROM", trim($str)); 
     60  $search = $IMAP->search($mbox, "HEADER SUBJECT", trim($str), $imap_charset); 
     61  $search2 = $IMAP->search($mbox, "HEADER FROM", trim($str), $imap_charset); 
    5762  finish_search($mbox, array_unique(array_merge($search, $search2))); 
    5863} 
Note: See TracChangeset for help on using the changeset viewer.