diff options
Diffstat (limited to 'program/lib')
-rw-r--r-- | program/lib/Mail/mime.php | 27 | ||||
-rw-r--r-- | program/lib/Mail/mimePart.php | 9 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube.php | 5 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_html2text.php | 2 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_imap.php | 51 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_imap_search.php | 25 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_ldap_generic.php | 3 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_result_multifolder.php | 27 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_storage.php | 13 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_string_replacer.php | 2 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_text2html.php | 4 |
11 files changed, 101 insertions, 67 deletions
diff --git a/program/lib/Mail/mime.php b/program/lib/Mail/mime.php index e079af7e9..50297dd3e 100644 --- a/program/lib/Mail/mime.php +++ b/program/lib/Mail/mime.php @@ -491,13 +491,13 @@ class Mail_mime * returns it during the build process. * * @param mixed &$obj The object to add the part to, or - * null if a new object is to be created. + * anything else if a new object is to be created. * @param string $text The text to add. * * @return object The text mimePart object * @access private */ - function &_addTextPart(&$obj = null, $text = '') + function &_addTextPart(&$obj, $text = '') { $params['content_type'] = 'text/plain'; $params['encoding'] = $this->_build_params['text_encoding']; @@ -518,12 +518,12 @@ class Mail_mime * returns it during the build process. * * @param mixed &$obj The object to add the part to, or - * null if a new object is to be created. + * anything else if a new object is to be created. * * @return object The html mimePart object * @access private */ - function &_addHtmlPart(&$obj = null) + function &_addHtmlPart(&$obj) { $params['content_type'] = 'text/html'; $params['encoding'] = $this->_build_params['html_encoding']; @@ -563,12 +563,12 @@ class Mail_mime * the build process. * * @param mixed &$obj The object to add the part to, or - * null if a new object is to be created. + * anything else if a new object is to be created. * * @return object The multipart/mixed mimePart object * @access private */ - function &_addAlternativePart(&$obj = null) + function &_addAlternativePart(&$obj) { $params['content_type'] = 'multipart/alternative'; $params['eol'] = $this->_build_params['eol']; @@ -588,12 +588,12 @@ class Mail_mime * the build process. * * @param mixed &$obj The object to add the part to, or - * null if a new object is to be created + * anything else if a new object is to be created * * @return object The multipart/mixed mimePart object * @access private */ - function &_addRelatedPart(&$obj = null) + function &_addRelatedPart(&$obj) { $params['content_type'] = 'multipart/related'; $params['eol'] = $this->_build_params['eol']; @@ -878,11 +878,11 @@ class Mail_mime $this->_checkParams(); - $null = null; - $attachments = count($this->_parts) ? true : false; - $html_images = count($this->_html_images) ? true : false; - $html = strlen($this->_htmlbody) ? true : false; - $text = (!$html && strlen($this->_txtbody)) ? true : false; + $null = -1; + $attachments = count($this->_parts) > 0; + $html_images = count($this->_html_images) > 0; + $html = strlen($this->_htmlbody) > 0; + $text = !$html && strlen($this->_txtbody); switch (true) { case $text && !$attachments: @@ -991,7 +991,6 @@ class Mail_mime $this->_addAttachmentPart($message, $this->_parts[$i]); } break; - } if (!isset($message)) { diff --git a/program/lib/Mail/mimePart.php b/program/lib/Mail/mimePart.php index c6e9f4aa8..93e891bc6 100644 --- a/program/lib/Mail/mimePart.php +++ b/program/lib/Mail/mimePart.php @@ -839,7 +839,7 @@ class Mail_mimePart // Simple e-mail address regexp $email_regexp = '([^\s<]+|("[^\r\n"]+"))@\S+'; - $parts = Mail_mimePart::_explodeQuotedString($separator, $value); + $parts = Mail_mimePart::_explodeQuotedString("[\t$separator]", $value); $value = ''; foreach ($parts as $part) { @@ -850,7 +850,7 @@ class Mail_mimePart continue; } if ($value) { - $value .= $separator==',' ? $separator.' ' : ' '; + $value .= $separator == ',' ? $separator . ' ' : ' '; } else { $value = $name . ': '; } @@ -869,7 +869,7 @@ class Mail_mimePart // check if phrase requires quoting if ($word) { // non-ASCII: require encoding - if (preg_match('#([\x80-\xFF]){1}#', $word)) { + if (preg_match('#([^\s\x21-\x7E]){1}#', $word)) { if ($word[0] == '"' && $word[strlen($word)-1] == '"') { // de-quote quoted-string, encoding changes // string to atom @@ -908,11 +908,10 @@ class Mail_mimePart $value = preg_replace( '/^'.$name.':('.preg_quote($eol, '/').')* /', '', $value ); - } else { // Unstructured header // non-ASCII: require encoding - if (preg_match('#([\x80-\xFF]){1}#', $value)) { + if (preg_match('#([^\s\x21-\x7E]){1}#', $value)) { if ($value[0] == '"' && $value[strlen($value)-1] == '"') { // de-quote quoted-string, encoding changes // string to atom diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index f2aeda7f0..d618fb64d 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -1132,6 +1132,11 @@ class rcube return true; } + // add session ID to the log + if ($sess = session_id()) { + $line = '<' . substr($sess, 0, 8) . '> ' . $line; + } + if ($log_driver == 'syslog') { $prio = $name == 'errors' ? LOG_ERR : LOG_INFO; syslog($prio, $line); diff --git a/program/lib/Roundcube/rcube_html2text.php b/program/lib/Roundcube/rcube_html2text.php index 8628371d7..499c4b05c 100644 --- a/program/lib/Roundcube/rcube_html2text.php +++ b/program/lib/Roundcube/rcube_html2text.php @@ -423,7 +423,7 @@ class rcube_html2text // Variables used for building the link list $this->_link_list = array(); - $text = trim(stripslashes($this->html)); + $text = $this->html; // Convert HTML to TXT $this->_converter($text); diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index 4204354b3..4b32c466b 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -1489,23 +1489,39 @@ class rcube_imap extends rcube_storage * Invoke search request to IMAP server * * @param string $folder Folder name to search in - * @param string $str Search criteria + * @param string $search Search criteria * @param string $charset Search charset * @param string $sort_field Header field to sort by + * * @return rcube_result_index Search result object * @todo: Search criteria should be provided in non-IMAP format, eg. array */ - public function search($folder='', $str='ALL', $charset=NULL, $sort_field=NULL) + public function search($folder = '', $search = 'ALL', $charset = null, $sort_field = null) { - if (!$str) { - $str = 'ALL'; + if (!$search) { + $search = 'ALL'; } - // multi-folder search - if (is_array($folder) && count($folder) > 1 && $str != 'ALL') { - new rcube_result_index; // trigger autoloader and make these classes available for threaded context - new rcube_result_thread; + if ((is_array($folder) && empty($folder)) || (!is_array($folder) && !strlen($folder))) { + $folder = $this->folder; + } + + $plugin = rcube::get_instance()->plugins->exec_hook('imap_search_before', array( + 'folder' => $folder, + 'search' => $search, + 'charset' => $charset, + 'sort_field' => $sort_field, + 'threading' => $this->threading, + )); + + $folder = $plugin['folder']; + $search = $plugin['search']; + $charset = $plugin['charset']; + $sort_field = $plugin['sort_field']; + $results = $plugin['result']; + // multi-folder search + if (!$results && is_array($folder) && count($folder) > 1 && $search != 'ALL') { // connect IMAP to have all the required classes and settings loaded $this->check_connection(); @@ -1518,29 +1534,28 @@ class rcube_imap extends rcube_storage $searcher->set_timelimit(60); // continue existing incomplete search - if (!empty($this->search_set) && $this->search_set->incomplete && $str == $this->search_string) { + if (!empty($this->search_set) && $this->search_set->incomplete && $search == $this->search_string) { $searcher->set_results($this->search_set); } // execute the search $results = $searcher->exec( $folder, - $str, + $search, $charset ? $charset : $this->default_charset, $sort_field && $this->get_capability('SORT') ? $sort_field : null, $this->threading ); } - else { - $folder = is_array($folder) ? $folder[0] : $folder; - if (!strlen($folder)) { - $folder = $this->folder; - } - $results = $this->search_index($folder, $str, $charset, $sort_field); + else if (!$results) { + $folder = is_array($folder) ? $folder[0] : $folder; + $search = is_array($search) ? $search[$folder] : $search; + $results = $this->search_index($folder, $search, $charset, $sort_field); } - $this->set_search_set(array($str, $results, $charset, $sort_field, - $this->threading || $this->search_sorted ? true : false)); + $sorted = $this->threading || $this->search_sorted || $plugin['search_sorted'] ? true : false; + + $this->set_search_set(array($search, $results, $charset, $sort_field, $sorted)); return $results; } diff --git a/program/lib/Roundcube/rcube_imap_search.php b/program/lib/Roundcube/rcube_imap_search.php index 0c44daf1b..365d78f76 100644 --- a/program/lib/Roundcube/rcube_imap_search.php +++ b/program/lib/Roundcube/rcube_imap_search.php @@ -29,7 +29,7 @@ class rcube_imap_search { public $options = array(); - protected $jobs = array(); + protected $jobs = array(); protected $timelimit = 0; protected $results; protected $conn; @@ -40,7 +40,7 @@ class rcube_imap_search public function __construct($options, $conn) { $this->options = $options; - $this->conn = $conn; + $this->conn = $conn; } /** @@ -54,7 +54,7 @@ class rcube_imap_search */ public function exec($folders, $str, $charset = null, $sort_field = null, $threading=null) { - $start = floor(microtime(true)); + $start = floor(microtime(true)); $results = new rcube_result_multifolder($folders); // start a search job for every folder to search in @@ -65,7 +65,8 @@ class rcube_imap_search $results->add($result); } else { - $job = new rcube_imap_search_job($folder, $str, $charset, $sort_field, $threading); + $search = is_array($str) && $str[$folder] ? $str[$folder] : $str; + $job = new rcube_imap_search_job($folder, $search, $charset, $sort_field, $threading); $job->worker = $this; $this->jobs[] = $job; } @@ -129,11 +130,11 @@ class rcube_imap_search_job /* extends Stackable */ public function __construct($folder, $str, $charset = null, $sort_field = null, $threading=false) { - $this->folder = $folder; - $this->search = $str; - $this->charset = $charset; + $this->folder = $folder; + $this->search = $str; + $this->charset = $charset; $this->sort_field = $sort_field; - $this->threading = $threading; + $this->threading = $threading; $this->result = new rcube_result_index($folder); $this->result->incomplete = true; @@ -150,9 +151,8 @@ class rcube_imap_search_job /* extends Stackable */ protected function search_index() { $criteria = $this->search; - $charset = $this->charset; - - $imap = $this->worker->get_imap(); + $charset = $this->charset; + $imap = $this->worker->get_imap(); if (!$imap->connected()) { trigger_error("No IMAP connection for $this->folder", E_USER_WARNING); @@ -228,7 +228,4 @@ class rcube_imap_search_job /* extends Stackable */ { return $this->result; } - } - - diff --git a/program/lib/Roundcube/rcube_ldap_generic.php b/program/lib/Roundcube/rcube_ldap_generic.php index f1048ef39..f6f9884d8 100644 --- a/program/lib/Roundcube/rcube_ldap_generic.php +++ b/program/lib/Roundcube/rcube_ldap_generic.php @@ -190,6 +190,9 @@ class rcube_ldap_generic if (isset($this->config['referrals'])) ldap_set_option($lc, LDAP_OPT_REFERRALS, $this->config['referrals']); + + if (isset($this->config['dereference'])) + ldap_set_option($lc, LDAP_OPT_DEREF, $this->config['dereference']); } else { $this->_debug("S: NOT OK"); diff --git a/program/lib/Roundcube/rcube_result_multifolder.php b/program/lib/Roundcube/rcube_result_multifolder.php index 4bbd2188d..786ee85f6 100644 --- a/program/lib/Roundcube/rcube_result_multifolder.php +++ b/program/lib/Roundcube/rcube_result_multifolder.php @@ -26,16 +26,16 @@ */ class rcube_result_multifolder { - public $multi = true; - public $sets = array(); + public $multi = true; + public $sets = array(); public $incomplete = false; public $folder; - protected $meta = array(); - protected $index = array(); + protected $meta = array(); + protected $index = array(); protected $folders = array(); + protected $order = 'ASC'; protected $sorting; - protected $order = 'ASC'; /** @@ -44,7 +44,7 @@ class rcube_result_multifolder public function __construct($folders = array()) { $this->folders = $folders; - $this->meta = array('count' => 0); + $this->meta = array('count' => 0); } @@ -74,7 +74,8 @@ class rcube_result_multifolder // append UIDs to global index $folder = $result->get_parameters('MAILBOX'); - $index = array_map(function($uid) use ($folder) { return $uid . '-' . $folder; }, $result->get()); + $index = array_map(function($uid) use ($folder) { return $uid . '-' . $folder; }, $result->get()); + $this->index = array_merge($this->index, $index); } @@ -89,7 +90,7 @@ class rcube_result_multifolder } $this->sorting = $sort_field; - $this->order = $sort_order; + $this->order = $sort_order; } /** @@ -150,8 +151,10 @@ class rcube_result_multifolder if ($this->order != $set->get_parameters('ORDER')) { $set->revert(); } + $folder = $set->get_parameters('MAILBOX'); - $index = array_map(function($uid) use ($folder) { return $uid . '-' . $folder; }, $set->get()); + $index = array_map(function($uid) use ($folder) { return $uid . '-' . $folder; }, $set->get()); + $this->index = array_merge($this->index, $index); } } @@ -171,6 +174,7 @@ class rcube_result_multifolder if (!empty($this->folder)) { $msgid .= '-' . $this->folder; } + return array_search($msgid, $this->index); } @@ -188,6 +192,7 @@ class rcube_result_multifolder if ($set->get_parameters('MAILBOX') == $folder) { $set->filter($ids); } + $this->meta['count'] += $set->count(); } } @@ -267,8 +272,8 @@ class rcube_result_multifolder public function get_parameters($param=null) { $params = array( - 'SORT' => $this->sorting, - 'ORDER' => $this->order, + 'SORT' => $this->sorting, + 'ORDER' => $this->order, 'MAILBOX' => $this->folders, ); diff --git a/program/lib/Roundcube/rcube_storage.php b/program/lib/Roundcube/rcube_storage.php index 69d6d2fae..c1293961c 100644 --- a/program/lib/Roundcube/rcube_storage.php +++ b/program/lib/Roundcube/rcube_storage.php @@ -152,6 +152,19 @@ abstract class rcube_storage /** + * Get connection/class option + * + * @param string $name Option name + * + * @param mixed Option value + */ + public function get_option($name) + { + return $this->options[$name]; + } + + + /** * Activate/deactivate debug mode. * * @param boolean $dbg True if conversation with the server should be logged diff --git a/program/lib/Roundcube/rcube_string_replacer.php b/program/lib/Roundcube/rcube_string_replacer.php index 77b91d18b..ce61e5367 100644 --- a/program/lib/Roundcube/rcube_string_replacer.php +++ b/program/lib/Roundcube/rcube_string_replacer.php @@ -42,7 +42,7 @@ class rcube_string_replacer // Support unicode/punycode in top-level domain part $utf_domain = '[^?&@"\'\\/()<>\s\r\t\n]+\\.?([^\\x00-\\x2f\\x3b-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-zA-Z0-9]{2,})'; $url1 = '.:;,'; - $url2 = 'a-zA-Z0-9%=#$@+?|!&\\/_~\\[\\]\\(\\){}\*-'; + $url2 = 'a-zA-Z0-9%=#$@+?|!&\\/_~\\[\\]\\(\\){}\*\x80-\xFE-'; $this->link_pattern = "/([\w]+:\/\/|\W[Ww][Ww][Ww]\.|^[Ww][Ww][Ww]\.)($utf_domain([$url1]*[$url2]+)*)/"; $this->mailto_pattern = "/(" diff --git a/program/lib/Roundcube/rcube_text2html.php b/program/lib/Roundcube/rcube_text2html.php index 363f1b21f..46c2b7e9a 100644 --- a/program/lib/Roundcube/rcube_text2html.php +++ b/program/lib/Roundcube/rcube_text2html.php @@ -127,10 +127,8 @@ class rcube_text2html */ protected function _convert() { - $text = stripslashes($this->text); - // Convert TXT to HTML - $this->html = $this->_converter($text); + $this->html = $this->_converter($this->text); $this->_converted = true; } |