diff options
author | Aleksander Machniak <alec@alec.pl> | 2012-09-20 13:15:03 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2012-09-20 13:15:03 +0200 |
commit | cd97f0ad1190f4fe1f65542389b517936bf32b5d (patch) | |
tree | 10ce77964e27640fc109c3d9dd91c80534c24035 | |
parent | 270da4b87b3601b558d37721aae9e4816359aca5 (diff) |
Support only 00 version of draft-ietf-sieve-notify which is more common (Cyrus 2.4)
-rw-r--r-- | plugins/managesieve/Changelog | 2 | ||||
-rw-r--r-- | plugins/managesieve/lib/rcube_sieve_script.php | 29 | ||||
-rw-r--r-- | plugins/managesieve/tests/src/parser_notify_a | 4 |
3 files changed, 29 insertions, 6 deletions
diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index 32eb3cb14..6fcd17a95 100644 --- a/plugins/managesieve/Changelog +++ b/plugins/managesieve/Changelog @@ -1,5 +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-04) +- 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 fe63141fe..36eb1bcf8 100644 --- a/plugins/managesieve/lib/rcube_sieve_script.php +++ b/plugins/managesieve/lib/rcube_sieve_script.php @@ -42,7 +42,7 @@ class rcube_sieve_script 'body', // RFC5173 'subaddress', // RFC5233 'enotify', // RFC5435 - 'notify', // draft-ietf-sieve-notify-04 + 'notify', // draft-ietf-sieve-notify-00 // @TODO: spamtest+virustest, mailbox, date ); @@ -408,11 +408,25 @@ class rcube_sieve_script 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'])) { @@ -869,13 +883,22 @@ class rcube_sieve_script 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] == ':') { - $notify[substr($tok, 1)] = $tokens[++$i]; + // 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 @@ -891,7 +914,7 @@ class rcube_sieve_script 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 */ + // 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); } diff --git a/plugins/managesieve/tests/src/parser_notify_a b/plugins/managesieve/tests/src/parser_notify_a index a8b44c583..f1a57540e 100644 --- a/plugins/managesieve/tests/src/parser_notify_a +++ b/plugins/managesieve/tests/src/parser_notify_a @@ -2,7 +2,7 @@ require ["notify","variables"]; # rule:[notify1] if header :contains "from" "boss@example.org" { - notify :importance "1" :message "This is probably very important"; + notify :low :message "This is probably very important"; stop; } # rule:[subject] @@ -14,5 +14,5 @@ if header :matches "Subject" "*" if header :matches "From" "*" { set "from" "${1}"; - notify :importance "3" :message "${from}: ${subject}" :method "mailto:test@example.org"; + notify :high :message "${from}: ${subject}" :method "mailto:test@example.org"; } |