diff options
-rw-r--r-- | config/db.inc.php.dist | 1 | ||||
-rw-r--r-- | plugins/database_attachments/database_attachments.php | 32 | ||||
-rw-r--r-- | plugins/http_authentication/http_authentication.php | 86 | ||||
-rw-r--r-- | plugins/http_authentication/package.xml | 6 | ||||
-rw-r--r-- | plugins/managesieve/Changelog | 1 | ||||
-rw-r--r-- | plugins/managesieve/lib/rcube_sieve_script.php | 96 | ||||
-rw-r--r-- | plugins/managesieve/localization/en_GB.inc | 9 | ||||
-rw-r--r-- | plugins/managesieve/localization/en_US.inc | 9 | ||||
-rw-r--r-- | plugins/managesieve/localization/pl_PL.inc | 9 | ||||
-rw-r--r-- | plugins/managesieve/managesieve.js | 6 | ||||
-rw-r--r-- | plugins/managesieve/managesieve.php | 60 | ||||
-rw-r--r-- | plugins/managesieve/package.xml | 4 | ||||
-rw-r--r-- | plugins/managesieve/tests/Parser.php | 10 | ||||
-rw-r--r-- | plugins/managesieve/tests/src/parser_notify_a | 18 | ||||
-rw-r--r-- | plugins/managesieve/tests/src/parser_notify_b | 17 | ||||
-rw-r--r-- | program/include/rcube_addressbook.php | 2 | ||||
-rw-r--r-- | program/include/rcube_db.php | 18 | ||||
-rw-r--r-- | tests/phpunit.xml | 2 |
18 files changed, 313 insertions, 73 deletions
diff --git a/config/db.inc.php.dist b/config/db.inc.php.dist index a02d7dc5b..49ec245ad 100644 --- a/config/db.inc.php.dist +++ b/config/db.inc.php.dist @@ -58,7 +58,6 @@ $rcmail_config['db_sequence_users'] = 'user_ids'; $rcmail_config['db_sequence_identities'] = 'identity_ids'; $rcmail_config['db_sequence_contacts'] = 'contact_ids'; $rcmail_config['db_sequence_contactgroups'] = 'contactgroups_ids'; -$rcmail_config['db_sequence_cache'] = 'cache_ids'; $rcmail_config['db_sequence_searches'] = 'search_ids'; diff --git a/plugins/database_attachments/database_attachments.php b/plugins/database_attachments/database_attachments.php index 9a279f57e..079f4e567 100644 --- a/plugins/database_attachments/database_attachments.php +++ b/plugins/database_attachments/database_attachments.php @@ -46,9 +46,9 @@ class database_attachments extends filesystem_attachments $data = base64_encode($data); $status = $rcmail->db->query( - "INSERT INTO ".get_table_name('cache')." - (created, user_id, cache_key, data) - VALUES (".$rcmail->db->now().", ?, ?, ?)", + "INSERT INTO ".get_table_name('cache') + ." (created, user_id, cache_key, data)" + ." VALUES (".$rcmail->db->now().", ?, ?, ?)", $_SESSION['user_id'], $key, $data); @@ -82,9 +82,9 @@ class database_attachments extends filesystem_attachments $data = base64_encode($args['data']); $status = $rcmail->db->query( - "INSERT INTO ".get_table_name('cache')." - (created, user_id, cache_key, data) - VALUES (".$rcmail->db->now().", ?, ?, ?)", + "INSERT INTO ".get_table_name('cache') + ." (created, user_id, cache_key, data)" + ." VALUES (".$rcmail->db->now().", ?, ?, ?)", $_SESSION['user_id'], $key, $data); @@ -106,9 +106,9 @@ class database_attachments extends filesystem_attachments $args['status'] = false; $rcmail = rcmail::get_instance(); $status = $rcmail->db->query( - "DELETE FROM ".get_table_name('cache')." - WHERE user_id=? - AND cache_key=?", + "DELETE FROM ".get_table_name('cache') + ." WHERE user_id = ?" + ." AND cache_key = ?", $_SESSION['user_id'], $args['id']); @@ -138,10 +138,10 @@ class database_attachments extends filesystem_attachments $rcmail = rcmail::get_instance(); $sql_result = $rcmail->db->query( - "SELECT cache_id, data - FROM ".get_table_name('cache')." - WHERE user_id=? - AND cache_key=?", + "SELECT data" + ." FROM ".get_table_name('cache') + ." WHERE user_id=?" + ." AND cache_key=?", $_SESSION['user_id'], $args['id']); @@ -161,9 +161,9 @@ class database_attachments extends filesystem_attachments $prefix = $this->cache_prefix . $args['group']; $rcmail = rcmail::get_instance(); $rcmail->db->query( - "DELETE FROM ".get_table_name('cache')." - WHERE user_id=? - AND cache_key like '{$prefix}%'", + "DELETE FROM ".get_table_name('cache') + ." WHERE user_id = ?" + ." AND cache_key LIKE '{$prefix}%'", $_SESSION['user_id']); } } diff --git a/plugins/http_authentication/http_authentication.php b/plugins/http_authentication/http_authentication.php index 6c873713e..a14b5cbcc 100644 --- a/plugins/http_authentication/http_authentication.php +++ b/plugins/http_authentication/http_authentication.php @@ -17,51 +17,67 @@ */ class http_authentication extends rcube_plugin { - public $task = 'login|logout'; - function init() - { - $this->add_hook('startup', array($this, 'startup')); - $this->add_hook('authenticate', array($this, 'authenticate')); - $this->add_hook('logout_after', array($this, 'logout')); - } + function init() + { + $this->add_hook('startup', array($this, 'startup')); + $this->add_hook('authenticate', array($this, 'authenticate')); + $this->add_hook('logout_after', array($this, 'logout')); + } - function startup($args) - { - // change action to login - if (empty($args['action']) && empty($_SESSION['user_id']) - && !empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) - $args['action'] = 'login'; + function startup($args) + { + if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) { + $rcmail = rcmail::get_instance(); + $rcmail->add_shutdown_function(array('http_authentication', 'shutdown')); - return $args; - } + // handle login action + if (empty($args['action']) && empty($_SESSION['user_id'])) { + $args['action'] = 'login'; + } + // Set user password in session (see shutdown() method for more info) + else if (!empty($_SESSION['user_id']) && empty($_SESION['password'])) { + $_SESSION['password'] = $rcmail->encrypt($_SERVER['PHP_AUTH_PW']); + } + } - function authenticate($args) - { - // Allow entering other user data in login form, - // e.g. after log out (#1487953) - if (!empty($args['user'])) { return $args; } - if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) { - $args['user'] = $_SERVER['PHP_AUTH_USER']; - $args['pass'] = $_SERVER['PHP_AUTH_PW']; - } + function authenticate($args) + { + // Allow entering other user data in login form, + // e.g. after log out (#1487953) + if (!empty($args['user'])) { + return $args; + } - $args['cookiecheck'] = false; - $args['valid'] = true; + if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) { + $args['user'] = $_SERVER['PHP_AUTH_USER']; + $args['pass'] = $_SERVER['PHP_AUTH_PW']; + } - return $args; - } - - function logout($args) - { - // redirect to configured URL in order to clear HTTP auth credentials - if (!empty($_SERVER['PHP_AUTH_USER']) && $args['user'] == $_SERVER['PHP_AUTH_USER'] && ($url = rcmail::get_instance()->config->get('logout_url'))) { - header("Location: $url", true, 307); + $args['cookiecheck'] = false; + $args['valid'] = true; + + return $args; } - } + function logout($args) + { + // redirect to configured URL in order to clear HTTP auth credentials + if (!empty($_SERVER['PHP_AUTH_USER']) && $args['user'] == $_SERVER['PHP_AUTH_USER']) { + if ($url = rcmail::get_instance()->config->get('logout_url')) { + header("Location: $url", true, 307); + } + } + } + + function shutdown() + { + // There's no need to store password (even if encrypted) in session + // We'll set it back on startup (#1486553) + rcmail::get_instance()->session->remove('password'); + } } diff --git a/plugins/http_authentication/package.xml b/plugins/http_authentication/package.xml index d8f2036b6..aab3819a8 100644 --- a/plugins/http_authentication/package.xml +++ b/plugins/http_authentication/package.xml @@ -13,10 +13,10 @@ <email>roundcube@gmail.com</email> <active>yes</active> </lead> - <date>2011-11-21</date> + <date>2012-09-18</date> <version> - <release>1.4</release> - <api>1.4</api> + <release>1.5</release> + <api>1.5</api> </version> <stability> <release>stable</release> diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index 482cff0ca..6fcd17a95 100644 --- a/plugins/managesieve/Changelog +++ b/plugins/managesieve/Changelog @@ -1,4 +1,5 @@ - Fixed issue with DBMail bug [http://pear.php.net/bugs/bug.php?id=19077] (#1488594) +- Added support for enotify/notify (RFC5435, RFC5436, draft-ietf-sieve-notify-00) * version 5.2 [2012-07-24] ----------------------------------------------------------- diff --git a/plugins/managesieve/lib/rcube_sieve_script.php b/plugins/managesieve/lib/rcube_sieve_script.php index aa3b9ab6e..36eb1bcf8 100644 --- a/plugins/managesieve/lib/rcube_sieve_script.php +++ b/plugins/managesieve/lib/rcube_sieve_script.php @@ -41,7 +41,9 @@ class rcube_sieve_script 'variables', // RFC5229 'body', // RFC5173 'subaddress', // RFC5233 - // @TODO: enotify/notify, spamtest+virustest, mailbox, date + 'enotify', // RFC5435 + 'notify', // draft-ietf-sieve-notify-00 + // @TODO: spamtest+virustest, mailbox, date ); /** @@ -198,6 +200,9 @@ class rcube_sieve_script } } + $imapflags = in_array('imap4flags', $this->supported) ? 'imap4flags' : 'imapflags'; + $notify = in_array('enotify', $this->supported) ? 'enotify' : 'notify'; + // rules foreach ($this->content as $rule) { $extension = ''; @@ -370,11 +375,7 @@ class rcube_sieve_script case 'addflag': case 'setflag': case 'removeflag': - if (in_array('imap4flags', $this->supported)) - array_push($exts, 'imap4flags'); - else - array_push($exts, 'imapflags'); - + array_push($exts, $imapflags); $action_script .= $action['type'].' ' . self::escape_string($action['target']); break; @@ -403,6 +404,46 @@ class rcube_sieve_script $action_script .= self::escape_string($action['name']) . ' ' . self::escape_string($action['value']); break; + case 'notify': + array_push($exts, $notify); + $action_script .= 'notify'; + + // Here we support only 00 version of notify draft, there + // were a couple regressions in 00 to 04 changelog, we use + // the version used by Cyrus + if ($notify == 'notify') { + switch ($action['importance']) { + case 1: $action_script .= " :high"; break; + case 2: $action_script .= " :normal"; break; + case 3: $action_script .= " :low"; break; + + } + unset($action['importance']); + } + + foreach (array('from', 'importance', 'options', 'message') as $n_tag) { + if (!empty($action[$n_tag])) { + $action_script .= " :$n_tag " . self::escape_string($action[$n_tag]); + } + } + + if (!empty($action['address'])) { + $method = 'mailto:' . $action['address']; + if (!empty($action['body'])) { + $method .= '?body=' . rawurlencode($action['body']); + } + } + else { + $method = $action['method']; + } + + // method is optional in notify extension + if (!empty($method)) { + $action_script .= ($notify == 'notify' ? " :method " : " ") . self::escape_string($method); + } + + break; + case 'vacation': array_push($exts, 'vacation'); $action_script .= 'vacation'; @@ -840,6 +881,49 @@ class rcube_sieve_script // $result[] = array('type' => 'require', 'target' => $tokens); break; + case 'notify': + $notify = array('type' => 'notify'); + $priorities = array(':high' => 1, ':normal' => 2, ':low' => 3); + + // Parameters: :from, :importance, :options, :message + // additional (optional) :method parameter for notify extension + for ($i=0, $len=count($tokens); $i<$len; $i++) { + $tok = strtolower($tokens[$i]); + if ($tok[0] == ':') { + // Here we support only 00 version of notify draft, there + // were a couple regressions in 00 to 04 changelog, we use + // the version used by Cyrus + if (isset($priorities[$tok])) { + $notify['importance'] = $priorities[$tok]; + } + else { + $notify[substr($tok, 1)] = $tokens[++$i]; + } + } + else { + // unnamed parameter is a :method in enotify extension + $notify['method'] = $tokens[$i]; + } + } + + $method_components = parse_url($notify['method']); + if ($method_components['scheme'] == 'mailto') { + $notify['address'] = $method_components['path']; + $method_params = array(); + if (array_key_exists('query', $method_components)) { + parse_str($method_components['query'], $method_params); + } + $method_params = array_change_key_case($method_params, CASE_LOWER); + // magic_quotes_gpc and magic_quotes_sybase affect the output of parse_str + if (ini_get('magic_quotes_gpc') || ini_get('magic_quotes_sybase')) { + array_map('stripslashes', $method_params); + } + $notify['body'] = (array_key_exists('body', $method_params)) ? $method_params['body'] : ''; + } + + $result[] = $notify; + break; + } if ($separator == $end) diff --git a/plugins/managesieve/localization/en_GB.inc b/plugins/managesieve/localization/en_GB.inc index 6859f5fff..f9075b8e0 100644 --- a/plugins/managesieve/localization/en_GB.inc +++ b/plugins/managesieve/localization/en_GB.inc @@ -97,6 +97,15 @@ $labels['setvariable'] = 'Set variable'; $labels['setvarname'] = 'Variable name:'; $labels['setvarvalue'] = 'Variable value:'; $labels['setvarmodifiers'] = 'Modifiers:'; +$labels['notify'] = 'Send notification'; +$labels['notifyaddress'] = 'To e-mail address:'; +$labels['notifybody'] = 'Notification body:'; +$labels['notifysubject'] = 'Notification subject:'; +$labels['notifyfrom'] = 'Notification sender:'; +$labels['notifyimportance'] = 'Importance:'; +$labels['notifyimportancelow'] = 'low'; +$labels['notifyimportancenormal'] = 'normal'; +$labels['notifyimportancehigh'] = 'high'; $labels['filtercreate'] = 'Create filter'; $labels['usedata'] = 'Use following data in the filter:'; $labels['nextstep'] = 'Next Step'; diff --git a/plugins/managesieve/localization/en_US.inc b/plugins/managesieve/localization/en_US.inc index 191291338..cb223c18f 100644 --- a/plugins/managesieve/localization/en_US.inc +++ b/plugins/managesieve/localization/en_US.inc @@ -88,6 +88,15 @@ $labels['varlowerfirst'] = 'first character lower-case'; $labels['varupperfirst'] = 'first character upper-case'; $labels['varquotewildcard'] = 'quote special characters'; $labels['varlength'] = 'length'; +$labels['notify'] = 'Send notification'; +$labels['notifyaddress'] = 'To e-mail address:'; +$labels['notifybody'] = 'Notification body:'; +$labels['notifysubject'] = 'Notification subject:'; +$labels['notifyfrom'] = 'Notification sender:'; +$labels['notifyimportance'] = 'Importance:'; +$labels['notifyimportancelow'] = 'low'; +$labels['notifyimportancenormal'] = 'normal'; +$labels['notifyimportancehigh'] = 'high'; $labels['filtercreate'] = 'Create filter'; $labels['usedata'] = 'Use following data in the filter:'; $labels['nextstep'] = 'Next Step'; diff --git a/plugins/managesieve/localization/pl_PL.inc b/plugins/managesieve/localization/pl_PL.inc index 0b4cb6073..734a4ebcf 100644 --- a/plugins/managesieve/localization/pl_PL.inc +++ b/plugins/managesieve/localization/pl_PL.inc @@ -103,6 +103,15 @@ $labels['varlowerfirst'] = 'pierwsza litera mała (:lowerfirst)'; $labels['varupperfirst'] = 'pierwsza litera duża (:upperfirst)'; $labels['varquotewildcard'] = 'anulowane znaki specjalne (:quotewildcard)'; $labels['varlength'] = 'długość (:length)'; +$labels['notify'] = 'Wyślij powiadomienie'; +$labels['notifyaddress'] = 'Na adres e-mail:'; +$labels['notifybody'] = 'Treść powiadomienia:'; +$labels['notifysubject'] = 'Temat powiadomienia:'; +$labels['notifyfrom'] = 'Nadawca powiadomienia:'; +$labels['notifyimportance'] = 'Priorytet:'; +$labels['notifyimportancelow'] = 'niski'; +$labels['notifyimportancenormal'] = 'normalny'; +$labels['notifyimportancehigh'] = 'wysoki'; $labels['filtercreate'] = 'Utwórz filtr'; $labels['usedata'] = 'Użyj następujących danych do utworzenia filtra:'; $labels['nextstep'] = 'Następny krok'; diff --git a/plugins/managesieve/managesieve.js b/plugins/managesieve/managesieve.js index f447719a2..bbc10793c 100644 --- a/plugins/managesieve/managesieve.js +++ b/plugins/managesieve/managesieve.js @@ -639,7 +639,8 @@ function action_type_select(id) target_area: document.getElementById('action_target_area' + id), flags: document.getElementById('action_flags' + id), vacation: document.getElementById('action_vacation' + id), - set: document.getElementById('action_set' + id) + set: document.getElementById('action_set' + id), + notify: document.getElementById('action_notify' + id) }; if (obj.value == 'fileinto' || obj.value == 'fileinto_copy') { @@ -660,6 +661,9 @@ function action_type_select(id) else if (obj.value == 'set') { enabled.set = 1; } + else if (obj.value == 'notify') { + enabled.notify = 1; + } for (var x in elems) { elems[x].style.display = !enabled[x] ? 'none' : 'inline'; diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index e7828f1da..ccfc95076 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -625,6 +625,11 @@ class managesieve extends rcube_plugin $varnames = get_input_value('_action_varname', RCUBE_INPUT_POST); $varvalues = get_input_value('_action_varvalue', RCUBE_INPUT_POST); $varmods = get_input_value('_action_varmods', RCUBE_INPUT_POST); + $notifyaddrs = get_input_value('_action_notifyaddress', RCUBE_INPUT_POST); + $notifybodies = get_input_value('_action_notifybody', RCUBE_INPUT_POST); + $notifymessages = get_input_value('_action_notifymessage', RCUBE_INPUT_POST); + $notifyfrom = get_input_value('_action_notifyfrom', RCUBE_INPUT_POST); + $notifyimp = get_input_value('_action_notifyimportance', RCUBE_INPUT_POST); // we need a "hack" for radiobuttons foreach ($sizeitems as $item) @@ -878,6 +883,23 @@ class managesieve extends rcube_plugin $this->errors['actions'][$i]['value'] = $this->gettext('cannotbeempty'); } break; + + case 'notify': + if (empty($notifyaddrs[$idx])) { + $this->errors['actions'][$i]['address'] = $this->gettext('cannotbeempty'); + } + else if (!check_email($notifyaddrs[$idx])) { + $this->errors['actions'][$i]['address'] = $this->gettext('noemailwarning'); + } + if (!empty($notifyfrom[$idx]) && !check_email($notifyfrom[$idx])) { + $this->errors['actions'][$i]['from'] = $this->gettext('noemailwarning'); + } + $this->form['actions'][$i]['address'] = $notifyaddrs[$idx]; + $this->form['actions'][$i]['body'] = $notifybodies[$idx]; + $this->form['actions'][$i]['message'] = $notifymessages[$idx]; + $this->form['actions'][$i]['from'] = $notifyfrom[$idx]; + $this->form['actions'][$i]['importance'] = $notifyimp[$idx]; + break; } $this->form['actions'][$i]['type'] = $type; @@ -1479,6 +1501,9 @@ class managesieve extends rcube_plugin if (in_array('variables', $this->exts)) { $select_action->add(Q($this->gettext('setvariable')), 'set'); } + if (in_array('enotify', $this->exts) || in_array('notify', $this->exts)) { + $select_action->add(Q($this->gettext('notify')), 'notify'); + } $select_action->add(Q($this->gettext('rulestop')), 'stop'); $select_type = $action['type']; @@ -1571,6 +1596,41 @@ class managesieve extends rcube_plugin } $out .= '</div>'; + // notify + // skip :options tag - not used by the mailto method + $out .= '<div id="action_notify' .$id.'" style="display:' .($action['type']=='notify' ? 'inline' : 'none') .'">'; + $out .= '<span class="label">' .Q($this->gettext('notifyaddress')) . '</span><br />' + .'<input type="text" name="_action_notifyaddress['.$id.']" id="action_notifyaddress'.$id.'" ' + .'value="' . Q($action['address']) . '" size="35" ' + . $this->error_class($id, 'action', 'address', 'action_notifyaddress') .' />'; + $out .= '<br /><span class="label">'. Q($this->gettext('notifybody')) .'</span><br />' + .'<textarea name="_action_notifybody['.$id.']" id="action_notifybody' .$id. '" ' + .'rows="3" cols="35" '. $this->error_class($id, 'action', 'method', 'action_notifybody') . '>' + . Q($action['body'], 'strict', false) . "</textarea>\n"; + $out .= '<br /><span class="label">' .Q($this->gettext('notifysubject')) . '</span><br />' + .'<input type="text" name="_action_notifymessage['.$id.']" id="action_notifymessage'.$id.'" ' + .'value="' . Q($action['message']) . '" size="35" ' + . $this->error_class($id, 'action', 'message', 'action_notifymessage') .' />'; + $out .= '<br /><span class="label">' .Q($this->gettext('notifyfrom')) . '</span><br />' + .'<input type="text" name="_action_notifyfrom['.$id.']" id="action_notifyfrom'.$id.'" ' + .'value="' . Q($action['from']) . '" size="35" ' + . $this->error_class($id, 'action', 'from', 'action_notifyfrom') .' />'; + $importance_options = array( + 3 => 'notifyimportancelow', + 2 => 'notifyimportancenormal', + 1 => 'notifyimportancehigh' + ); + $select_importance = new html_select(array( + 'name' => '_action_notifyimportance[' . $id . ']', + 'id' => '_action_notifyimportance' . $id, + 'class' => $this->error_class($id, 'action', 'importance', 'action_notifyimportance'))); + foreach ($importance_options as $io_v => $io_n) { + $select_importance->add(Q($this->gettext($io_n)), $io_v); + } + $out .= '<br /><span class="label">' . Q($this->gettext('notifyimportance')) . '</span><br />'; + $out .= $select_importance->show($action['importance'] ? $action['importance'] : 2); + $out .= '</div>'; + // mailbox select if ($action['type'] == 'fileinto') $mailbox = $this->mod_mailbox($action['target'], 'out'); diff --git a/plugins/managesieve/package.xml b/plugins/managesieve/package.xml index cde78c9a3..20fec7895 100644 --- a/plugins/managesieve/package.xml +++ b/plugins/managesieve/package.xml @@ -17,9 +17,9 @@ <email>alec@alec.pl</email> <active>yes</active> </lead> - <date>2012-06-21</date> + <date>2012-07-24</date> <version> - <release>5.1</release> + <release>5.2</release> <api>5.0</api> </version> <stability> diff --git a/plugins/managesieve/tests/Parser.php b/plugins/managesieve/tests/Parser.php index 00915cc20..2f24870e2 100644 --- a/plugins/managesieve/tests/Parser.php +++ b/plugins/managesieve/tests/Parser.php @@ -15,7 +15,15 @@ class Parser extends PHPUnit_Framework_TestCase */ function test_parser($input, $output, $message) { - $script = new rcube_sieve_script($input); + // get capabilities list from the script + $caps = array(); + if (preg_match('/require \[([a-z0-9", ]+)\]/', $input, $m)) { + foreach (explode(',', $m[1]) as $cap) { + $caps[] = trim($cap, '" '); + } + } + + $script = new rcube_sieve_script($input, $caps); $result = $script->as_text(); $this->assertEquals(trim($result), trim($output), $message); diff --git a/plugins/managesieve/tests/src/parser_notify_a b/plugins/managesieve/tests/src/parser_notify_a new file mode 100644 index 000000000..f1a57540e --- /dev/null +++ b/plugins/managesieve/tests/src/parser_notify_a @@ -0,0 +1,18 @@ +require ["notify","variables"]; +# rule:[notify1] +if header :contains "from" "boss@example.org" +{ + notify :low :message "This is probably very important"; + stop; +} +# rule:[subject] +if header :matches "Subject" "*" +{ + set "subject" "${1}"; +} +# rule:[from notify2] +if header :matches "From" "*" +{ + set "from" "${1}"; + notify :high :message "${from}: ${subject}" :method "mailto:test@example.org"; +} diff --git a/plugins/managesieve/tests/src/parser_notify_b b/plugins/managesieve/tests/src/parser_notify_b new file mode 100644 index 000000000..cf80a9701 --- /dev/null +++ b/plugins/managesieve/tests/src/parser_notify_b @@ -0,0 +1,17 @@ +require ["envelope","variables","notify"]; +# rule:[from] +if envelope :all :matches "from" "*" +{ + set "env_from" " [really: ${1}]"; +} +# rule:[subject] +if header :matches "Subject" "*" +{ + set "subject" "${1}"; +} +# rule:[from notify] +if address :all :matches "from" "*" +{ + set "from_addr" "${1}"; + notify :message "${from_addr}${env_from}: ${subject}" :method "sms:1234567890"; +} diff --git a/program/include/rcube_addressbook.php b/program/include/rcube_addressbook.php index 069ea5715..f4f255322 100644 --- a/program/include/rcube_addressbook.php +++ b/program/include/rcube_addressbook.php @@ -465,7 +465,7 @@ abstract class rcube_addressbook $fn = $contact['name']; if (!$fn) // default display name composition according to vcard standard - $fn = join(' ', array_filter(array($contact['prefix'], $contact['firstname'], $contact['middlename'], $contact['surname'], $contact['suffix']))); + $fn = trim(join(' ', array_filter(array($contact['prefix'], $contact['firstname'], $contact['middlename'], $contact['surname'], $contact['suffix'])))); // use email address part for name $email = is_array($contact['email']) ? $contact['email'][0] : $contact['email']; diff --git a/program/include/rcube_db.php b/program/include/rcube_db.php index f97d70ab3..eb1ad31b2 100644 --- a/program/include/rcube_db.php +++ b/program/include/rcube_db.php @@ -388,13 +388,19 @@ class rcube_db $idx = 0; while ($pos = strpos($query, '?', $pos)) { - $val = $this->quote($params[$idx++]); - unset($params[$idx-1]); - $query = substr_replace($query, $val, $pos, 1); - $pos += strlen($val); + if ($query[$pos+1] == '?') { // skip escaped ? + $pos += 2; + } + else { + $val = $this->quote($params[$idx++]); + unset($params[$idx-1]); + $query = substr_replace($query, $val, $pos, 1); + $pos += strlen($val); + } } - $query = rtrim($query, ';'); + // replace escaped ? back to normal + $query = rtrim(strtr($query, array('??' => '?')), ';'); $this->debug($query); @@ -591,7 +597,7 @@ class rcube_db 'integer' => PDO::PARAM_INT, ); $type = isset($map[$type]) ? $map[$type] : PDO::PARAM_STR; - return $this->dbh->quote($input, $type); + return strtr($this->dbh->quote($input, $type), array('?' => '??')); // escape ? } return 'NULL'; diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 8b3883223..43c3b767d 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -29,7 +29,7 @@ <file>HtmlToText.php</file> <file>MailFunc.php</file> </testsuite> - <testsuite name="managesieve"> + <testsuite name="Managesieve Tests"> <file>./../plugins/managesieve/tests/Parser.php</file> <file>./../plugins/managesieve/tests/Tokenizer.php</file> </testsuite> |