thomascube
2007-03-13 568ba395b6ca0a5779600a435a9906ae88de6d5f
program/include/rcube_imap.inc
@@ -878,7 +878,8 @@
      {
      $results = array();
      foreach ($criteria as $crit)
        $results = array_merge($results, $this->search($mbox_name, $crit, $str, $charset));
        if ($search_result = $this->search($mbox_name, $crit, $str, $charset))
          $results = array_merge($results, $search_result);
      
      $results = array_unique($results);
      $this->set_search_set($criteria, $str, $results, $charset);
@@ -2453,12 +2454,12 @@
  function _parse_address_list($str)
    {
    // remove any newlines and carriage returns before
    $a = $this->_explode_quoted_string(',', preg_replace( "/[\r\n]/", " ", $str));
    $a = $this->_explode_quoted_string('[,;]', preg_replace( "/[\r\n]/", " ", $str));
    $result = array();
    
    foreach ($a as $key => $val)
      {
      $val = str_replace("\"<", "\" <", $val);
      $val = preg_replace("/([\"\w])</", "$1 <", $val);
      $sub_a = $this->_explode_quoted_string(' ', $this->decode_header($val));
      $result[$key]['name'] = '';
@@ -2480,17 +2481,20 @@
  function _explode_quoted_string($delimiter, $string)
    {
    $quotes = explode("\"", $string);
    foreach ($quotes as $key => $val)
      if (($key % 2) == 1)
        $quotes[$key] = str_replace($delimiter, "_!@!_", $quotes[$key]);
    $string = implode("\"", $quotes);
    $result = explode($delimiter, $string);
    foreach ($result as $key => $val)
      $result[$key] = str_replace("_!@!_", $delimiter, $result[$key]);
    $result = array();
    $strlen = strlen($string);
    for ($q=$p=$i=0; $i < $strlen; $i++)
    {
      if ($string{$i} == "\"" && $string{$i-1} != "\\")
        $q = $q ? false : true;
      else if (!$q && preg_match("/$delimiter/", $string{$i}))
      {
        $result[] = substr($string, $p, $i - $p);
        $p = $i + 1;
      }
    }
    
    $result[] = substr($string, $p);
    return $result;
    }
  }