From a1303514933afe2d867067e4b95412c79652c89b Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Tue, 14 Aug 2012 23:25:36 +0200 Subject: Codestyle --- program/include/rcube_utils.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/program/include/rcube_utils.php b/program/include/rcube_utils.php index 9344a929b..8762a2018 100644 --- a/program/include/rcube_utils.php +++ b/program/include/rcube_utils.php @@ -617,8 +617,8 @@ class rcube_utils // %n - host $n = preg_replace('/:\d+$/', '', $_SERVER['SERVER_NAME']); // %t - host name without first part, e.g. %n=mail.domain.tld, %t=domain.tld - $t = preg_replace('/^[^\.]+\./', '', $n); - // %d - domain name without first part + $t = preg_replace('/^[^\.]+\./', '', $n); + // %d - domain name without first part $d = preg_replace('/^[^\.]+\./', '', $_SERVER['HTTP_HOST']); // %h - IMAP host $h = $_SESSION['storage_host'] ? $_SESSION['storage_host'] : $host; @@ -627,7 +627,7 @@ class rcube_utils // %s - domain name after the '@' from e-mail address provided at login screen. Returns FALSE if an invalid email is provided if (strpos($name, '%s') !== false) { $user_email = self::get_input_value('_user', self::INPUT_POST); - $user_email = rcube_utils::idn_convert($user_email, true); + $user_email = self::idn_convert($user_email, true); $matches = preg_match('/(.*)@([a-z0-9\.\-\[\]\:]+)/i', $user_email, $s); if ($matches < 1 || filter_var($s[1]."@".$s[2], FILTER_VALIDATE_EMAIL) === false) { return false; -- cgit v1.2.3 From 2ac00a258b9aa859ea78da25cd906e1709df5b75 Mon Sep 17 00:00:00 2001 From: Paweł Słowik Date: Thu, 30 Aug 2012 19:31:40 +0200 Subject: Sieve enotify/notify - parser --- plugins/managesieve/lib/rcube_sieve_script.php | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/plugins/managesieve/lib/rcube_sieve_script.php b/plugins/managesieve/lib/rcube_sieve_script.php index aa3b9ab6e..66bedb52b 100644 --- a/plugins/managesieve/lib/rcube_sieve_script.php +++ b/plugins/managesieve/lib/rcube_sieve_script.php @@ -403,6 +403,20 @@ class rcube_sieve_script $action_script .= self::escape_string($action['name']) . ' ' . self::escape_string($action['value']); break; + case 'notify': + array_push($exts, 'enotify'); + $action_script .= 'notify'; + foreach (array('from', 'importance', 'options', 'message') as $n_tag) { + if (!empty($action[$n_tag])) { + $action_script .= " :$n_tag " . self::escape_string($action[$n_tag]); + } + } + $method = (!empty($action['address']) && !empty($action['body'])) ? + sprintf('mailto:%s?body=%s', $action['address'], rawurlencode($action['body'])) : + $action['method']; + $action_script .= " " . self::escape_string($method); + break; + case 'vacation': array_push($exts, 'vacation'); $action_script .= 'vacation'; @@ -840,6 +854,32 @@ class rcube_sieve_script // $result[] = array('type' => 'require', 'target' => $tokens); break; + case 'notify': + $notify = array('type' => 'notify', 'method' => array_pop($tokens)); + + // Parameters: :from, :importance, :options, :message + for ($i=0, $len=count($tokens); $i<$len; $i++) { + $tok = strtolower($tokens[$i]); + if ($tok[0] == ':') { + $notify[substr($tok, 1)] = $tokens[$i+1]; + } + } + $method_components = parse_url($notify['method']); + if ($method_components['scheme'] == 'mailto') { + $notify['address'] = $method_components['path']; + $method_params = array(); + 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'] = $method_params['body']; + } + + $result[] = $notify; + break; + } if ($separator == $end) -- cgit v1.2.3 From c142ab62f192a770b23b63d234ade57eb4015d2d Mon Sep 17 00:00:00 2001 From: Paweł Słowik Date: Thu, 30 Aug 2012 20:11:44 +0200 Subject: Sieve enotify/notify - parser --- plugins/managesieve/managesieve.js | 6 ++++- plugins/managesieve/managesieve.php | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) 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..16c451845 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -625,6 +625,10 @@ 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); // we need a "hack" for radiobuttons foreach ($sizeitems as $item) @@ -878,6 +882,22 @@ 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]; + break; } $this->form['actions'][$i]['type'] = $type; @@ -1479,6 +1499,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)) { + $select_action->add(Q($this->gettext('notify')), 'notify'); + } $select_action->add(Q($this->gettext('rulestop')), 'stop'); $select_type = $action['type']; @@ -1571,6 +1594,27 @@ class managesieve extends rcube_plugin } $out .= ''; + // notify + // skip :options tag - not used by the mailto method + $out .= '
'; + $out .= '' .Q($this->gettext('notifyaddress')) . '
' + .'error_class($id, 'action', 'address', 'action_notifyaddress') .' />'; + $out .= '
'. Q($this->gettext('notifybody')) .'
' + .'\n"; + $out .= '
' .Q($this->gettext('notifysubject')) . '
' + .'error_class($id, 'action', 'message', 'action_notifymessage') .' />'; + $out .= '
' .Q($this->gettext('notifyfrom')) . '
' + .'error_class($id, 'action', 'from', 'action_notifyfrom') .' />'; + $out .= '
'; + // mailbox select if ($action['type'] == 'fileinto') $mailbox = $this->mod_mailbox($action['target'], 'out'); -- cgit v1.2.3 From 2e7bd6dab7de8553984d1d31034b34c595cef5ee Mon Sep 17 00:00:00 2001 From: Paweł Słowik Date: Thu, 30 Aug 2012 20:11:44 +0200 Subject: Sieve enotify/notify - GUI --- plugins/managesieve/managesieve.js | 6 ++++- plugins/managesieve/managesieve.php | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) 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..16c451845 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -625,6 +625,10 @@ 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); // we need a "hack" for radiobuttons foreach ($sizeitems as $item) @@ -878,6 +882,22 @@ 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]; + break; } $this->form['actions'][$i]['type'] = $type; @@ -1479,6 +1499,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)) { + $select_action->add(Q($this->gettext('notify')), 'notify'); + } $select_action->add(Q($this->gettext('rulestop')), 'stop'); $select_type = $action['type']; @@ -1571,6 +1594,27 @@ class managesieve extends rcube_plugin } $out .= ''; + // notify + // skip :options tag - not used by the mailto method + $out .= '
'; + $out .= '' .Q($this->gettext('notifyaddress')) . '
' + .'error_class($id, 'action', 'address', 'action_notifyaddress') .' />'; + $out .= '
'. Q($this->gettext('notifybody')) .'
' + .'\n"; + $out .= '
' .Q($this->gettext('notifysubject')) . '
' + .'error_class($id, 'action', 'message', 'action_notifymessage') .' />'; + $out .= '
' .Q($this->gettext('notifyfrom')) . '
' + .'error_class($id, 'action', 'from', 'action_notifyfrom') .' />'; + $out .= '
'; + // mailbox select if ($action['type'] == 'fileinto') $mailbox = $this->mod_mailbox($action['target'], 'out'); -- cgit v1.2.3 From ffb160147a324f4b8744d13c97e1ca4177a8167a Mon Sep 17 00:00:00 2001 From: Paweł Słowik Date: Fri, 31 Aug 2012 11:45:11 +0200 Subject: Sieve enotify/notify - localization --- plugins/managesieve/localization/en_GB.inc | 5 +++++ plugins/managesieve/localization/en_US.inc | 5 +++++ plugins/managesieve/localization/pl_PL.inc | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/plugins/managesieve/localization/en_GB.inc b/plugins/managesieve/localization/en_GB.inc index 6859f5fff..7b02c8218 100644 --- a/plugins/managesieve/localization/en_GB.inc +++ b/plugins/managesieve/localization/en_GB.inc @@ -97,6 +97,11 @@ $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['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..bcef9139e 100644 --- a/plugins/managesieve/localization/en_US.inc +++ b/plugins/managesieve/localization/en_US.inc @@ -88,6 +88,11 @@ $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['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..5b51900e6 100644 --- a/plugins/managesieve/localization/pl_PL.inc +++ b/plugins/managesieve/localization/pl_PL.inc @@ -103,6 +103,11 @@ $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['filtercreate'] = 'Utwórz filtr'; $labels['usedata'] = 'Użyj następujących danych do utworzenia filtra:'; $labels['nextstep'] = 'Następny krok'; -- cgit v1.2.3 From 92a030d928246cfc5f3c0b1f2538dc1bfb4777e3 Mon Sep 17 00:00:00 2001 From: Paweł Słowik Date: Tue, 4 Sep 2012 14:59:15 +0200 Subject: Added tests, fixed PHP warnings --- plugins/managesieve/lib/rcube_sieve_script.php | 6 ++++-- plugins/managesieve/tests/src/parser_notify_a | 16 ++++++++++++++++ plugins/managesieve/tests/src/parser_notify_b | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 plugins/managesieve/tests/src/parser_notify_a create mode 100644 plugins/managesieve/tests/src/parser_notify_b diff --git a/plugins/managesieve/lib/rcube_sieve_script.php b/plugins/managesieve/lib/rcube_sieve_script.php index 66bedb52b..3e418edd3 100644 --- a/plugins/managesieve/lib/rcube_sieve_script.php +++ b/plugins/managesieve/lib/rcube_sieve_script.php @@ -868,13 +868,15 @@ class rcube_sieve_script if ($method_components['scheme'] == 'mailto') { $notify['address'] = $method_components['path']; $method_params = array(); - parse_str($method_components['query'], $method_params); + 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'] = $method_params['body']; + $notify['body'] = (array_key_exists('body', $method_params)) ? $method_params['body'] : ''; } $result[] = $notify; diff --git a/plugins/managesieve/tests/src/parser_notify_a b/plugins/managesieve/tests/src/parser_notify_a new file mode 100644 index 000000000..324805ad4 --- /dev/null +++ b/plugins/managesieve/tests/src/parser_notify_a @@ -0,0 +1,16 @@ +require ["enotify","variables"]; +if header :contains "from" "boss@example.org" +{ + notify :importance "1" :message "This is probably very important" "mailto:alm@example.com"; + stop; +} +if header :matches "Subject" "*" +{ + set "subject" "${1}"; +} +if header :matches "From" "*" +{ + set "from" "${1}"; +} +notify :importance "3" :message "${from}: ${subject}" "mailto:alm@example.com"; + diff --git a/plugins/managesieve/tests/src/parser_notify_b b/plugins/managesieve/tests/src/parser_notify_b new file mode 100644 index 000000000..537898567 --- /dev/null +++ b/plugins/managesieve/tests/src/parser_notify_b @@ -0,0 +1,15 @@ +require ["envelope","variables","enotify"]; +if envelope :all :matches "from" "*" +{ + set "env_from" " [really: ${1}]"; +} +if header :matches "Subject" "*" +{ + set "subject" "${1}"; +} +if address :all :matches "from" "*" +{ + set "from_addr" "${1}"; +} +notify :message "${from_addr}${env_from}: ${subject}" "mailto:alm@example.com"; + -- cgit v1.2.3 From 3c99599794948686960ee4e340374b0c3a1527b2 Mon Sep 17 00:00:00 2001 From: Paweł Słowik Date: Fri, 14 Sep 2012 14:27:58 +0200 Subject: Sieve enotify/notify: - GUI for importance setting - make tests usable for checking the GUI --- plugins/managesieve/localization/en_GB.inc | 4 ++++ plugins/managesieve/localization/en_US.inc | 4 ++++ plugins/managesieve/localization/pl_PL.inc | 4 ++++ plugins/managesieve/managesieve.php | 16 ++++++++++++++++ plugins/managesieve/tests/src/parser_notify_a | 5 ++++- plugins/managesieve/tests/src/parser_notify_b | 5 ++++- 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/plugins/managesieve/localization/en_GB.inc b/plugins/managesieve/localization/en_GB.inc index 7b02c8218..f9075b8e0 100644 --- a/plugins/managesieve/localization/en_GB.inc +++ b/plugins/managesieve/localization/en_GB.inc @@ -102,6 +102,10 @@ $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 bcef9139e..cb223c18f 100644 --- a/plugins/managesieve/localization/en_US.inc +++ b/plugins/managesieve/localization/en_US.inc @@ -93,6 +93,10 @@ $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 5b51900e6..734a4ebcf 100644 --- a/plugins/managesieve/localization/pl_PL.inc +++ b/plugins/managesieve/localization/pl_PL.inc @@ -108,6 +108,10 @@ $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.php b/plugins/managesieve/managesieve.php index 16c451845..e3033016b 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -629,6 +629,7 @@ class managesieve extends rcube_plugin $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) @@ -897,6 +898,7 @@ class managesieve extends rcube_plugin $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; } @@ -1613,6 +1615,20 @@ class managesieve extends rcube_plugin .'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 .= '
' . Q($this->gettext('notifyimportance')) . '
'; + $out .= $select_importance->show(array(intval($action['importance']))); $out .= ''; // mailbox select diff --git a/plugins/managesieve/tests/src/parser_notify_a b/plugins/managesieve/tests/src/parser_notify_a index 324805ad4..68a9ef5cc 100644 --- a/plugins/managesieve/tests/src/parser_notify_a +++ b/plugins/managesieve/tests/src/parser_notify_a @@ -1,16 +1,19 @@ require ["enotify","variables"]; +# rule:[notify1] if header :contains "from" "boss@example.org" { notify :importance "1" :message "This is probably very important" "mailto:alm@example.com"; stop; } +# rule:[subject] if header :matches "Subject" "*" { set "subject" "${1}"; } +# rule:[from notify2] if header :matches "From" "*" { set "from" "${1}"; + notify :importance "3" :message "${from}: ${subject}" "mailto:alm@example.com"; } -notify :importance "3" :message "${from}: ${subject}" "mailto:alm@example.com"; diff --git a/plugins/managesieve/tests/src/parser_notify_b b/plugins/managesieve/tests/src/parser_notify_b index 537898567..8854658f4 100644 --- a/plugins/managesieve/tests/src/parser_notify_b +++ b/plugins/managesieve/tests/src/parser_notify_b @@ -1,15 +1,18 @@ require ["envelope","variables","enotify"]; +# 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}" "mailto:alm@example.com"; } -notify :message "${from_addr}${env_from}: ${subject}" "mailto:alm@example.com"; -- cgit v1.2.3 From 4c4496bccc46e15f05d54235b420c0bff1306db2 Mon Sep 17 00:00:00 2001 From: Paweł Słowik Date: Fri, 14 Sep 2012 14:48:30 +0200 Subject: Sieve enotify/notify - allow empty body --- plugins/managesieve/lib/rcube_sieve_script.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/managesieve/lib/rcube_sieve_script.php b/plugins/managesieve/lib/rcube_sieve_script.php index 3e418edd3..debe9c124 100644 --- a/plugins/managesieve/lib/rcube_sieve_script.php +++ b/plugins/managesieve/lib/rcube_sieve_script.php @@ -411,9 +411,15 @@ class rcube_sieve_script $action_script .= " :$n_tag " . self::escape_string($action[$n_tag]); } } - $method = (!empty($action['address']) && !empty($action['body'])) ? - sprintf('mailto:%s?body=%s', $action['address'], rawurlencode($action['body'])) : - $action['method']; + if (!empty($action['address'])) { + $method = 'mailto:' . $action['address']; + if (!empty($action['body'])) { + $method .= '?body=' . rawurlencode($action['body']); + } + } + else { + $method = $action['method']; + } $action_script .= " " . self::escape_string($method); break; -- cgit v1.2.3 From 649cc19cfc0be218719e106680eba908bbb3d583 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 17 Sep 2012 14:22:44 +0200 Subject: Fix HTML special characters handling in message list/header display (#1488523) --- CHANGELOG | 1 + program/include/rcube_utils.php | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8a010a4d0..61eced8f3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Fix HTML special characters handling in message list/header display (#1488523) - List related text/html part as attachment in plain text mode (#1488677) - Use IMAP BINARY (RFC3516) extension to fetch message/part bodies - Fix folder creation under public namespace root (#1488665) diff --git a/program/include/rcube_utils.php b/program/include/rcube_utils.php index b278431a6..bf2b0db54 100644 --- a/program/include/rcube_utils.php +++ b/program/include/rcube_utils.php @@ -250,9 +250,6 @@ class rcube_utils $out = strtr($str, $encode_arr); - // avoid douple quotation of & - $out = preg_replace('/&([A-Za-z]{2,6}|#[0-9]{2,4});/', '&\\1;', $out); - return $newlines ? nl2br($out) : $out; } -- cgit v1.2.3 From d66e50d6b50523f68109c46b074b36fb161da552 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 17 Sep 2012 15:01:34 +0200 Subject: Remove double-quotation prevention code for form elements --- program/include/html.php | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/program/include/html.php b/program/include/html.php index c6507f813..948794283 100644 --- a/program/include/html.php +++ b/program/include/html.php @@ -295,7 +295,7 @@ class html } } else { - $attrib_arr[] = $key . '="' . self::quote($value, true) . '"'; + $attrib_arr[] = $key . '="' . self::quote($value) . '"'; } } @@ -328,22 +328,13 @@ class html /** * Replacing specials characters in html attribute value * - * @param string $str Input string - * @param bool $validate Enables double quotation prevention + * @param string $str Input string * - * @return string The quoted string + * @return string The quoted string */ - public static function quote($str, $validate = false) + public static function quote($str) { - $str = htmlspecialchars($str, ENT_COMPAT, RCMAIL_CHARSET); - - // avoid douple quotation of & - // @TODO: get rid of it - if ($validate) { - $str = preg_replace('/&([A-Za-z]{2,6}|#[0-9]{2,4});/', '&\\1;', $str); - } - - return $str; + return htmlspecialchars($str, ENT_COMPAT, RCMAIL_CHARSET); } } @@ -559,7 +550,7 @@ class html_textarea extends html } if (!empty($value) && empty($this->attrib['is_escaped'])) { - $value = self::quote($value, true); + $value = self::quote($value); } return self::tag($this->tagname, $this->attrib, $value, @@ -635,7 +626,7 @@ class html_select extends html $option_content = $option['text']; if (empty($this->attrib['is_escaped'])) { - $option_content = self::quote($option_content, true); + $option_content = self::quote($option_content); } $this->content .= self::tag('option', $attr, $option_content); -- cgit v1.2.3 From 0f38fad2ef54cee36a686a4344f1b0bf28e445ef Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 17 Sep 2012 15:12:40 +0200 Subject: Replace Q() with html::quote() --- program/include/rcube_output_html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/include/rcube_output_html.php b/program/include/rcube_output_html.php index 2743e7705..6138e2a30 100644 --- a/program/include/rcube_output_html.php +++ b/program/include/rcube_output_html.php @@ -527,7 +527,7 @@ class rcube_output_html extends rcube_output { $GLOBALS['__version'] = html::quote(RCMAIL_VERSION); $GLOBALS['__comm_path'] = html::quote($this->app->comm_path); - $GLOBALS['__skin_path'] = Q($this->config->get('skin_path')); + $GLOBALS['__skin_path'] = html::quote($this->config->get('skin_path')); return preg_replace_callback('/\$(__[a-z0-9_\-]+)/', array($this, 'globals_callback'), $input); -- cgit v1.2.3 From 4ca72140858e0b16fbfcba9042dd32f2465dc6d1 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 18 Sep 2012 10:19:13 +0200 Subject: Enable list sort command on empty folder (#1488617) --- program/js/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 2182a2b88..cf942e291 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -208,7 +208,7 @@ function rcube_webmail() this.gui_objects.messagelist.parentNode.onmousedown = function(e){ return p.click_on_list(e); }; this.message_list.init(); - this.enable_command('toggle_status', 'toggle_flag', 'menu-open', 'menu-save', true); + this.enable_command('toggle_status', 'toggle_flag', 'menu-open', 'menu-save', 'sort', true); // load messages this.command('list'); @@ -6114,7 +6114,7 @@ function rcube_webmail() this.show_contentframe(false); // disable commands useless when mailbox is empty this.enable_command(this.env.message_commands, 'purge', 'expunge', - 'select-all', 'select-none', 'sort', 'expand-all', 'expand-unread', 'collapse-all', false); + 'select-all', 'select-none', 'expand-all', 'expand-unread', 'collapse-all', false); } if (this.message_list) this.triggerEvent('listupdate', { folder:this.env.mailbox, rowcount:this.message_list.rowcount }); @@ -6127,7 +6127,7 @@ function rcube_webmail() this.env.qsearch = null; case 'list': if (this.task == 'mail') { - this.enable_command('show', 'expunge', 'select-all', 'select-none', 'sort', (this.env.messagecount > 0)); + this.enable_command('show', 'expunge', 'select-all', 'select-none', (this.env.messagecount > 0)); this.enable_command('purge', this.purge_mailbox_test()); this.enable_command('expand-all', 'expand-unread', 'collapse-all', this.env.threading && this.env.messagecount); -- cgit v1.2.3 From 4fd63805e59a4b196297e8d8627826f377ff8529 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Sep 2012 11:31:41 +0200 Subject: Fix exception on phpunit 3.6.11 --- tests/phpunit.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ HtmlToText.php MailFunc.php - + ./../plugins/managesieve/tests/Parser.php ./../plugins/managesieve/tests/Tokenizer.php -- cgit v1.2.3 From eb1ee0803e51fbbdd3f8966c511b5212aed91524 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Sep 2012 12:23:44 +0200 Subject: Support old notify extension --- plugins/managesieve/Changelog | 1 + plugins/managesieve/lib/rcube_sieve_script.php | 33 ++++++++++++++++++-------- plugins/managesieve/package.xml | 4 ++-- plugins/managesieve/tests/src/parser_notify_a | 7 +++--- plugins/managesieve/tests/src/parser_notify_b | 5 ++-- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index 482cff0ca..32eb3cb14 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-04) * 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 debe9c124..fe63141fe 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-04 + // @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; @@ -404,8 +405,9 @@ class rcube_sieve_script break; case 'notify': - array_push($exts, 'enotify'); + array_push($exts, $notify); $action_script .= 'notify'; + foreach (array('from', 'importance', 'options', 'message') as $n_tag) { if (!empty($action[$n_tag])) { $action_script .= " :$n_tag " . self::escape_string($action[$n_tag]); @@ -420,7 +422,12 @@ class rcube_sieve_script else { $method = $action['method']; } - $action_script .= " " . self::escape_string($method); + + // method is optional in notify extension + if (!empty($method)) { + $action_script .= ($notify == 'notify' ? " :method " : " ") . self::escape_string($method); + } + break; case 'vacation': @@ -861,15 +868,21 @@ class rcube_sieve_script break; case 'notify': - $notify = array('type' => 'notify', 'method' => array_pop($tokens)); + $notify = array('type' => 'notify'); // 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+1]; + $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']; 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 @@ alec@alec.pl yes - 2012-06-21 + 2012-07-24 - 5.1 + 5.2 5.0 diff --git a/plugins/managesieve/tests/src/parser_notify_a b/plugins/managesieve/tests/src/parser_notify_a index 68a9ef5cc..a8b44c583 100644 --- a/plugins/managesieve/tests/src/parser_notify_a +++ b/plugins/managesieve/tests/src/parser_notify_a @@ -1,8 +1,8 @@ -require ["enotify","variables"]; +require ["notify","variables"]; # rule:[notify1] if header :contains "from" "boss@example.org" { - notify :importance "1" :message "This is probably very important" "mailto:alm@example.com"; + notify :importance "1" :message "This is probably very important"; stop; } # rule:[subject] @@ -14,6 +14,5 @@ if header :matches "Subject" "*" if header :matches "From" "*" { set "from" "${1}"; - notify :importance "3" :message "${from}: ${subject}" "mailto:alm@example.com"; + notify :importance "3" :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 index 8854658f4..cf80a9701 100644 --- a/plugins/managesieve/tests/src/parser_notify_b +++ b/plugins/managesieve/tests/src/parser_notify_b @@ -1,4 +1,4 @@ -require ["envelope","variables","enotify"]; +require ["envelope","variables","notify"]; # rule:[from] if envelope :all :matches "from" "*" { @@ -13,6 +13,5 @@ if header :matches "Subject" "*" if address :all :matches "from" "*" { set "from_addr" "${1}"; - notify :message "${from_addr}${env_from}: ${subject}" "mailto:alm@example.com"; + notify :message "${from_addr}${env_from}: ${subject}" :method "sms:1234567890"; } - -- cgit v1.2.3 From 270da4b87b3601b558d37721aae9e4816359aca5 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Sep 2012 12:39:52 +0200 Subject: Enable notify action for notify extension --- plugins/managesieve/managesieve.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index e3033016b..055e1b4cb 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -1501,7 +1501,7 @@ 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)) { + 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'); -- cgit v1.2.3 From cd97f0ad1190f4fe1f65542389b517936bf32b5d Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Sep 2012 13:15:03 +0200 Subject: Support only 00 version of draft-ietf-sieve-notify which is more common (Cyrus 2.4) --- plugins/managesieve/Changelog | 2 +- plugins/managesieve/lib/rcube_sieve_script.php | 29 +++++++++++++++++++++++--- 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"; } -- cgit v1.2.3 From b41cd7cc37159ee69c96202faa84eb8a86eb379e Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Sep 2012 13:17:24 +0200 Subject: Set default importance to normal --- plugins/managesieve/managesieve.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index 055e1b4cb..ccfc95076 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -1628,7 +1628,7 @@ class managesieve extends rcube_plugin $select_importance->add(Q($this->gettext($io_n)), $io_v); } $out .= '
' . Q($this->gettext('notifyimportance')) . '
'; - $out .= $select_importance->show(array(intval($action['importance']))); + $out .= $select_importance->show($action['importance'] ? $action['importance'] : 2); $out .= ''; // mailbox select -- cgit v1.2.3 From 5802cfec95fc05f5ccab2c85ab225ffeaf1e5874 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Sep 2012 15:46:11 +0200 Subject: Support HTML entities in addressbook names --- program/steps/addressbook/func.inc | 3 ++- program/steps/settings/func.inc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index 5f5fcc673..44d216c25 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -219,12 +219,13 @@ function rcmail_directory_list($attrib) if ($source['class_name']) $class_name .= ' ' . $source['class_name']; + $name = !empty($source['name']) ? html_entity_decode($source['name'], ENT_COMPAT, 'UTF-8') : $id; $out .= sprintf($line_templ, html_identifier($id), $class_name, Q(rcmail_url(null, array('_source' => $id))), $source['id'], - $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id))); + $js_id, Q($name)); $groupdata = array('out' => $out, 'jsdata' => $jsdata, 'source' => $id); if ($source['groups']) diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 59b4e3735..4f8da1350 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -667,7 +667,7 @@ function rcmail_user_prefs($current=null) $select_abook = new html_select(array('name' => '_default_addressbook', 'id' => $field_id)); foreach ($books as $book) { - $select_abook->add($book['name'], $book['id']); + $select_abook->add(html_entity_decode($book['name'], ENT_COMPAT, 'UTF-8'), $book['id']); } $blocks['main']['options']['default_addressbook'] = array( -- cgit v1.2.3 From 2afd45dda078c35b43240a62569c73dc61739e81 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Sep 2012 15:59:07 +0200 Subject: Re-add enotify tests --- plugins/managesieve/tests/src/parser_enotify_a | 19 +++++++++++++++++++ plugins/managesieve/tests/src/parser_enotify_b | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 plugins/managesieve/tests/src/parser_enotify_a create mode 100644 plugins/managesieve/tests/src/parser_enotify_b diff --git a/plugins/managesieve/tests/src/parser_enotify_a b/plugins/managesieve/tests/src/parser_enotify_a new file mode 100644 index 000000000..68a9ef5cc --- /dev/null +++ b/plugins/managesieve/tests/src/parser_enotify_a @@ -0,0 +1,19 @@ +require ["enotify","variables"]; +# rule:[notify1] +if header :contains "from" "boss@example.org" +{ + notify :importance "1" :message "This is probably very important" "mailto:alm@example.com"; + stop; +} +# rule:[subject] +if header :matches "Subject" "*" +{ + set "subject" "${1}"; +} +# rule:[from notify2] +if header :matches "From" "*" +{ + set "from" "${1}"; + notify :importance "3" :message "${from}: ${subject}" "mailto:alm@example.com"; +} + diff --git a/plugins/managesieve/tests/src/parser_enotify_b b/plugins/managesieve/tests/src/parser_enotify_b new file mode 100644 index 000000000..8854658f4 --- /dev/null +++ b/plugins/managesieve/tests/src/parser_enotify_b @@ -0,0 +1,18 @@ +require ["envelope","variables","enotify"]; +# 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}" "mailto:alm@example.com"; +} + -- cgit v1.2.3 From 74e6cf2f58a663b50a9b443dd815e44451f7d770 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Sep 2012 15:59:07 +0200 Subject: Re-add enotify tests --- plugins/managesieve/tests/src/parser_enotify_a | 19 +++++++++++++++++++ plugins/managesieve/tests/src/parser_enotify_b | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 plugins/managesieve/tests/src/parser_enotify_a create mode 100644 plugins/managesieve/tests/src/parser_enotify_b diff --git a/plugins/managesieve/tests/src/parser_enotify_a b/plugins/managesieve/tests/src/parser_enotify_a new file mode 100644 index 000000000..68a9ef5cc --- /dev/null +++ b/plugins/managesieve/tests/src/parser_enotify_a @@ -0,0 +1,19 @@ +require ["enotify","variables"]; +# rule:[notify1] +if header :contains "from" "boss@example.org" +{ + notify :importance "1" :message "This is probably very important" "mailto:alm@example.com"; + stop; +} +# rule:[subject] +if header :matches "Subject" "*" +{ + set "subject" "${1}"; +} +# rule:[from notify2] +if header :matches "From" "*" +{ + set "from" "${1}"; + notify :importance "3" :message "${from}: ${subject}" "mailto:alm@example.com"; +} + diff --git a/plugins/managesieve/tests/src/parser_enotify_b b/plugins/managesieve/tests/src/parser_enotify_b new file mode 100644 index 000000000..8854658f4 --- /dev/null +++ b/plugins/managesieve/tests/src/parser_enotify_b @@ -0,0 +1,18 @@ +require ["envelope","variables","enotify"]; +# 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}" "mailto:alm@example.com"; +} + -- cgit v1.2.3 From 1b9923208c64f4d3494e185ac3d249df5fbb8552 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 21 Sep 2012 10:11:05 +0200 Subject: Re-fix HTML entities handling in addressbook names --- program/include/rcmail.php | 2 +- program/steps/addressbook/edit.inc | 7 ++++--- program/steps/addressbook/func.inc | 6 +++--- program/steps/addressbook/import.inc | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 5a9a1fa86..ee144faca 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -281,7 +281,7 @@ class rcmail extends rcube } $list[$id] = array( 'id' => $id, - 'name' => $prop['name'], + 'name' => html::quote($prop['name']), 'groups' => is_array($prop['groups']), 'readonly' => !$prop['writable'], 'hidden' => $prop['hidden'], diff --git a/program/steps/addressbook/edit.inc b/program/steps/addressbook/edit.inc index 90069a7eb..b216a7c70 100644 --- a/program/steps/addressbook/edit.inc +++ b/program/steps/addressbook/edit.inc @@ -244,11 +244,12 @@ function rcmail_source_selector($attrib) if (count($sources_list) < 2) { $source = $sources_list[$SOURCE_ID]; $hiddenfield = new html_hiddenfield(array('name' => '_source', 'value' => $SOURCE_ID)); - return html::span($attrib, Q($source['name']) . $hiddenfield->show()); + return html::span($attrib, $source['name'] . $hiddenfield->show()); } - $attrib['name'] = '_source'; - $attrib['onchange'] = JS_OBJECT_NAME . ".command('save', 'reload', this.form)"; + $attrib['name'] = '_source'; + $attrib['is_escaped'] = true; + $attrib['onchange'] = JS_OBJECT_NAME . ".command('save', 'reload', this.form)"; $select = new html_select($attrib); diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index 44d216c25..4ef4d1b51 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -178,7 +178,7 @@ function rcmail_set_sourcename($abook) if (!$name && $source == 0) { $name = rcube_label('personaladrbook'); } - $OUTPUT->set_env('sourcename', $name); + $OUTPUT->set_env('sourcename', html_entity_decode($name, ENT_COMPAT, 'UTF-8')); } } @@ -219,13 +219,13 @@ function rcmail_directory_list($attrib) if ($source['class_name']) $class_name .= ' ' . $source['class_name']; - $name = !empty($source['name']) ? html_entity_decode($source['name'], ENT_COMPAT, 'UTF-8') : $id; + $name = !empty($source['name']) ? $source['name'] : $id; $out .= sprintf($line_templ, html_identifier($id), $class_name, Q(rcmail_url(null, array('_source' => $id))), $source['id'], - $js_id, Q($name)); + $js_id, $name); $groupdata = array('out' => $out, 'jsdata' => $jsdata, 'source' => $id); if ($source['groups']) diff --git a/program/steps/addressbook/import.inc b/program/steps/addressbook/import.inc index 15e04b82a..fb2251f18 100644 --- a/program/steps/addressbook/import.inc +++ b/program/steps/addressbook/import.inc @@ -43,7 +43,7 @@ function rcmail_import_form($attrib) // addressbook selector if (count($writable_books) > 1) { - $select = new html_select(array('name' => '_target', 'id' => 'rcmimporttarget')); + $select = new html_select(array('name' => '_target', 'id' => 'rcmimporttarget', 'is_escaped' => true)); foreach ($writable_books as $book) $select->add($book['name'], $book['id']); -- cgit v1.2.3 From 97313ac258914e4c26aefec912e8677d8436175e Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 21 Sep 2012 10:18:09 +0200 Subject: Fix test for html::quote() --- tests/Framework/Html.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/Framework/Html.php b/tests/Framework/Html.php index 8a27baca8..60284deef 100644 --- a/tests/Framework/Html.php +++ b/tests/Framework/Html.php @@ -31,7 +31,6 @@ class Framework_Html extends PHPUnit_Framework_TestCase array('>', '>'), array('&', '&'), array('&', '&amp;'), - array('&', '&', true), ); } @@ -39,8 +38,8 @@ class Framework_Html extends PHPUnit_Framework_TestCase * Test for quote() * @dataProvider data_quote */ - function test_quote($str, $result, $validate = false) + function test_quote($str, $result) { - $this->assertEquals(html::quote($str, $validate), $result); + $this->assertEquals(html::quote($str), $result); } } -- cgit v1.2.3 From e695162ef76054050e4181e4d28f28cf1981386b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 21 Sep 2012 20:57:53 +0200 Subject: Change default port to 4190 (IANA-allocated), add port auto-detection (#1488713) --- plugins/managesieve/Changelog | 1 + plugins/managesieve/config.inc.php.dist | 5 +++-- plugins/managesieve/managesieve.php | 19 +++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index 6fcd17a95..a1dd7e0ca 100644 --- a/plugins/managesieve/Changelog +++ b/plugins/managesieve/Changelog @@ -1,5 +1,6 @@ - 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) +- Change default port to 4190 (IANA-allocated), add port auto-detection (#1488713) * version 5.2 [2012-07-24] ----------------------------------------------------------- diff --git a/plugins/managesieve/config.inc.php.dist b/plugins/managesieve/config.inc.php.dist index cb9b2a97f..1f34564c5 100644 --- a/plugins/managesieve/config.inc.php.dist +++ b/plugins/managesieve/config.inc.php.dist @@ -1,7 +1,8 @@ * * Configuration (see config.inc.php.dist) * - * Copyright (C) 2008-2011, The Roundcube Dev Team - * Copyright (C) 2011, Kolab Systems AG + * Copyright (C) 2008-2012, The Roundcube Dev Team + * Copyright (C) 2011-2012, Kolab Systems AG * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 @@ -62,8 +62,9 @@ class managesieve extends rcube_plugin "x-beenthere", ); - const VERSION = '5.2'; + const VERSION = '5.2'; const PROGNAME = 'Roundcube (Managesieve)'; + const PORT = 4190; function init() @@ -200,10 +201,16 @@ class managesieve extends rcube_plugin set_include_path($include_path); $host = rcube_parse_host($this->rc->config->get('managesieve_host', 'localhost')); - $port = $this->rc->config->get('managesieve_port', 2000); - $host = rcube_idn_to_ascii($host); + $port = $this->rc->config->get('managesieve_port'); + if (empty($port)) { + $port = getservbyname('sieve', 'tcp'); + if (empty($port)) { + $port = self::PORT; + } + } + $plugin = $this->rc->plugins->exec_hook('managesieve_connect', array( 'user' => $_SESSION['username'], 'password' => $this->rc->decrypt($_SESSION['password']), -- cgit v1.2.3 From 70bbabb6994e67f812d9f7d1f85df1098870cfaa Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Sun, 23 Sep 2012 22:46:09 +0200 Subject: Add zipdwonload plugin by Phil Weir at tehinterweb.co.uk to core repository --- plugins/zipdownload/CHANGELOG | 34 +++ plugins/zipdownload/README | 35 +++ plugins/zipdownload/config.inc.php | 21 ++ plugins/zipdownload/config.inc.php.dist | 21 ++ plugins/zipdownload/localization/ca_ES.inc | 10 + plugins/zipdownload/localization/cs_CZ.inc | 10 + plugins/zipdownload/localization/da_DK.inc | 10 + plugins/zipdownload/localization/de_CH.inc | 10 + plugins/zipdownload/localization/de_DE.inc | 10 + plugins/zipdownload/localization/en_GB.inc | 10 + plugins/zipdownload/localization/en_US.inc | 10 + plugins/zipdownload/localization/es_AR.inc | 9 + plugins/zipdownload/localization/es_ES.inc | 10 + plugins/zipdownload/localization/et_EE.inc | 9 + plugins/zipdownload/localization/fr_FR.inc | 10 + plugins/zipdownload/localization/gl_ES.inc | 10 + plugins/zipdownload/localization/hu_HU.inc | 10 + plugins/zipdownload/localization/it_IT.inc | 10 + plugins/zipdownload/localization/nl_NL.inc | 10 + plugins/zipdownload/localization/pl_PL.inc | 10 + plugins/zipdownload/localization/pt_BR.inc | 9 + plugins/zipdownload/localization/ro_RO.inc | 9 + plugins/zipdownload/localization/ru_RU.inc | 10 + plugins/zipdownload/localization/tr_TR.inc | 10 + plugins/zipdownload/package.xml | 89 ++++++++ plugins/zipdownload/skins/classic/zip.png | Bin 0 -> 546 bytes plugins/zipdownload/skins/classic/zipdownload.css | 8 + plugins/zipdownload/skins/larry/zipdownload.css | 7 + plugins/zipdownload/zipdownload.js | 33 +++ plugins/zipdownload/zipdownload.php | 267 ++++++++++++++++++++++ 30 files changed, 711 insertions(+) create mode 100644 plugins/zipdownload/CHANGELOG create mode 100644 plugins/zipdownload/README create mode 100644 plugins/zipdownload/config.inc.php create mode 100644 plugins/zipdownload/config.inc.php.dist create mode 100644 plugins/zipdownload/localization/ca_ES.inc create mode 100644 plugins/zipdownload/localization/cs_CZ.inc create mode 100644 plugins/zipdownload/localization/da_DK.inc create mode 100644 plugins/zipdownload/localization/de_CH.inc create mode 100644 plugins/zipdownload/localization/de_DE.inc create mode 100644 plugins/zipdownload/localization/en_GB.inc create mode 100644 plugins/zipdownload/localization/en_US.inc create mode 100644 plugins/zipdownload/localization/es_AR.inc create mode 100644 plugins/zipdownload/localization/es_ES.inc create mode 100644 plugins/zipdownload/localization/et_EE.inc create mode 100644 plugins/zipdownload/localization/fr_FR.inc create mode 100644 plugins/zipdownload/localization/gl_ES.inc create mode 100644 plugins/zipdownload/localization/hu_HU.inc create mode 100644 plugins/zipdownload/localization/it_IT.inc create mode 100644 plugins/zipdownload/localization/nl_NL.inc create mode 100644 plugins/zipdownload/localization/pl_PL.inc create mode 100644 plugins/zipdownload/localization/pt_BR.inc create mode 100644 plugins/zipdownload/localization/ro_RO.inc create mode 100644 plugins/zipdownload/localization/ru_RU.inc create mode 100644 plugins/zipdownload/localization/tr_TR.inc create mode 100644 plugins/zipdownload/package.xml create mode 100644 plugins/zipdownload/skins/classic/zip.png create mode 100644 plugins/zipdownload/skins/classic/zipdownload.css create mode 100644 plugins/zipdownload/skins/larry/zipdownload.css create mode 100644 plugins/zipdownload/zipdownload.js create mode 100644 plugins/zipdownload/zipdownload.php diff --git a/plugins/zipdownload/CHANGELOG b/plugins/zipdownload/CHANGELOG new file mode 100644 index 000000000..32b878e76 --- /dev/null +++ b/plugins/zipdownload/CHANGELOG @@ -0,0 +1,34 @@ +Roundcube Webmail ZipDownload +============================= + +2012-09-20 +========== + * Added style for new Larry skin + * Made plugin work with 0.8 version of Roundcube + * Save attachments to temp files before adding to zip archive (memory!) + +2011 03 12 +========== + * Convert charset for filenames inside zip + +2010 08 30 +========== + * Get all messages in folder, not just the first page + +2010 08 12 +========== + * Use $.inArray() instead of Array.indexOf() + +2010 08 07 +========== + * Add the ability to download a folder as zip + * Add the ability to download selection of messages as zip + * Add config file to control download options + +2010 05 29 +========== + * Remove tnef_decode, now done by message class (r3680) + +2010 02 21 +========== + * First version \ No newline at end of file diff --git a/plugins/zipdownload/README b/plugins/zipdownload/README new file mode 100644 index 000000000..4fa3c17b6 --- /dev/null +++ b/plugins/zipdownload/README @@ -0,0 +1,35 @@ +Roundcube Webmail ZipDownload +============================= +This plugin adds an option to download all attachments to a message in one zip +file, when a message has multiple attachments. The plugin also allows the +download of a selection of messages in 1 zip file and the download of entire +folders. + +Requirements +============ +* php_zip extension (including ZipArchive class) + Either install it via PECL or for PHP >= 5.2 compile with --enable-zip option + +License +======= +This plugin is released under the GNU General Public License Version 3 +or later (http://www.gnu.org/licenses/gpl.html). + +Even if skins might contain some programming work, they are not considered +as a linked part of the plugin and therefore skins DO NOT fall under the +provisions of the GPL license. See the README file located in the core skins +folder for details on the skin license. + +Install +======= +* Place this plugin folder into plugins directory of Roundcube +* Add zipdownload to $rcmail_config['plugins'] in your Roundcube config + +NB: When downloading the plugin from GitHub you will need to create a +directory called zipdownload and place the files in there, ignoring the +root directory in the downloaded archive + +Config +====== +The default config file is plugins/zipdownload/config.inc.php.dist +Rename this to plugins/zipdownload/config.inc.php \ No newline at end of file diff --git a/plugins/zipdownload/config.inc.php b/plugins/zipdownload/config.inc.php new file mode 100644 index 000000000..1eb6f06cb --- /dev/null +++ b/plugins/zipdownload/config.inc.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/config.inc.php.dist b/plugins/zipdownload/config.inc.php.dist new file mode 100644 index 000000000..5c7489a15 --- /dev/null +++ b/plugins/zipdownload/config.inc.php.dist @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/ca_ES.inc b/plugins/zipdownload/localization/ca_ES.inc new file mode 100644 index 000000000..8ccf0543c --- /dev/null +++ b/plugins/zipdownload/localization/ca_ES.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/cs_CZ.inc b/plugins/zipdownload/localization/cs_CZ.inc new file mode 100644 index 000000000..4a1f75177 --- /dev/null +++ b/plugins/zipdownload/localization/cs_CZ.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/da_DK.inc b/plugins/zipdownload/localization/da_DK.inc new file mode 100644 index 000000000..17c7c0d82 --- /dev/null +++ b/plugins/zipdownload/localization/da_DK.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/de_CH.inc b/plugins/zipdownload/localization/de_CH.inc new file mode 100644 index 000000000..68725605b --- /dev/null +++ b/plugins/zipdownload/localization/de_CH.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/de_DE.inc b/plugins/zipdownload/localization/de_DE.inc new file mode 100644 index 000000000..68725605b --- /dev/null +++ b/plugins/zipdownload/localization/de_DE.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/en_GB.inc b/plugins/zipdownload/localization/en_GB.inc new file mode 100644 index 000000000..0db6f8f8c --- /dev/null +++ b/plugins/zipdownload/localization/en_GB.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/en_US.inc b/plugins/zipdownload/localization/en_US.inc new file mode 100644 index 000000000..0db6f8f8c --- /dev/null +++ b/plugins/zipdownload/localization/en_US.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/es_AR.inc b/plugins/zipdownload/localization/es_AR.inc new file mode 100644 index 000000000..f3a798c85 --- /dev/null +++ b/plugins/zipdownload/localization/es_AR.inc @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/es_ES.inc b/plugins/zipdownload/localization/es_ES.inc new file mode 100644 index 000000000..193f7b450 --- /dev/null +++ b/plugins/zipdownload/localization/es_ES.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/et_EE.inc b/plugins/zipdownload/localization/et_EE.inc new file mode 100644 index 000000000..60a886b0a --- /dev/null +++ b/plugins/zipdownload/localization/et_EE.inc @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/fr_FR.inc b/plugins/zipdownload/localization/fr_FR.inc new file mode 100644 index 000000000..b8fc4cdaa --- /dev/null +++ b/plugins/zipdownload/localization/fr_FR.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/gl_ES.inc b/plugins/zipdownload/localization/gl_ES.inc new file mode 100644 index 000000000..2c9107949 --- /dev/null +++ b/plugins/zipdownload/localization/gl_ES.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/hu_HU.inc b/plugins/zipdownload/localization/hu_HU.inc new file mode 100644 index 000000000..1931cb0f2 --- /dev/null +++ b/plugins/zipdownload/localization/hu_HU.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/it_IT.inc b/plugins/zipdownload/localization/it_IT.inc new file mode 100644 index 000000000..63b7b072e --- /dev/null +++ b/plugins/zipdownload/localization/it_IT.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/nl_NL.inc b/plugins/zipdownload/localization/nl_NL.inc new file mode 100644 index 000000000..1cf32ce12 --- /dev/null +++ b/plugins/zipdownload/localization/nl_NL.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/pl_PL.inc b/plugins/zipdownload/localization/pl_PL.inc new file mode 100644 index 000000000..c86d87558 --- /dev/null +++ b/plugins/zipdownload/localization/pl_PL.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/pt_BR.inc b/plugins/zipdownload/localization/pt_BR.inc new file mode 100644 index 000000000..c082e541c --- /dev/null +++ b/plugins/zipdownload/localization/pt_BR.inc @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/ro_RO.inc b/plugins/zipdownload/localization/ro_RO.inc new file mode 100644 index 000000000..3a2a1ac19 --- /dev/null +++ b/plugins/zipdownload/localization/ro_RO.inc @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/ru_RU.inc b/plugins/zipdownload/localization/ru_RU.inc new file mode 100644 index 000000000..ac11327a0 --- /dev/null +++ b/plugins/zipdownload/localization/ru_RU.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/localization/tr_TR.inc b/plugins/zipdownload/localization/tr_TR.inc new file mode 100644 index 000000000..dc7489da1 --- /dev/null +++ b/plugins/zipdownload/localization/tr_TR.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/plugins/zipdownload/package.xml b/plugins/zipdownload/package.xml new file mode 100644 index 000000000..bf5511563 --- /dev/null +++ b/plugins/zipdownload/package.xml @@ -0,0 +1,89 @@ + + + zipdownload + pear.roundcube.net + Download multiple attachments or messages in one zip file + Adds an option to download all attachments to a message in one zip file, when a message has multiple attachments. Also allows the download of a selection of messages in one zip file and the download of entire folders. + + Philip Weir + JohnDoh + roundcube@tehinterweb.co.uk + no + + + Thomas Bruederli + bruederli + roundcube@gmail.com + yes + + 2012-09-20 + + + 2.0 + 2.0 + + + stable + stable + + GNU GPLv3+ + Repo only + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.2.1 + + + 1.7.0 + + + zip + pecl.php.net + zip + + + + + diff --git a/plugins/zipdownload/skins/classic/zip.png b/plugins/zipdownload/skins/classic/zip.png new file mode 100644 index 000000000..c64fde89b Binary files /dev/null and b/plugins/zipdownload/skins/classic/zip.png differ diff --git a/plugins/zipdownload/skins/classic/zipdownload.css b/plugins/zipdownload/skins/classic/zipdownload.css new file mode 100644 index 000000000..2608fdfd0 --- /dev/null +++ b/plugins/zipdownload/skins/classic/zipdownload.css @@ -0,0 +1,8 @@ +/* Roundcube Zipdownload plugin styles for classic skin */ + +a.zipdownload { + display: inline-block; + padding: 0 0 2px 20px; + background: url(zip.png) 0 1px no-repeat; + font-style: italic; +} diff --git a/plugins/zipdownload/skins/larry/zipdownload.css b/plugins/zipdownload/skins/larry/zipdownload.css new file mode 100644 index 000000000..d719ac677 --- /dev/null +++ b/plugins/zipdownload/skins/larry/zipdownload.css @@ -0,0 +1,7 @@ +/* Roundcube Zipdownload plugin styles for skin "Larry" */ + +a.zipdownload { + display: inline-block; + margin-top: 1.5em; + padding: 3px 5px 4px 5px; +} \ No newline at end of file diff --git a/plugins/zipdownload/zipdownload.js b/plugins/zipdownload/zipdownload.js new file mode 100644 index 000000000..080dcd9e3 --- /dev/null +++ b/plugins/zipdownload/zipdownload.js @@ -0,0 +1,33 @@ +/** + * ZipDownload plugin script + */ + +function rcmail_zipmessages() { + if (rcmail.message_list && rcmail.message_list.get_selection().length > 1) { + rcmail.goto_url('plugin.zipdownload.zip_messages', '_mbox=' + urlencode(rcmail.env.mailbox) + '&_uid=' + rcmail.message_list.get_selection().join(',')); + } +} + +$(document).ready(function() { + if (window.rcmail) { + rcmail.addEventListener('init', function(evt) { + // register command (directly enable in message view mode) + rcmail.register_command('plugin.zipdownload.zip_folder', function() { + rcmail.goto_url('plugin.zipdownload.zip_folder', '_mbox=' + urlencode(rcmail.env.mailbox)); + }, rcmail.env.messagecount > 0); + + if (rcmail.message_list && rcmail.env.zipdownload_selection) { + rcmail.message_list.addEventListener('select', function(list) { + rcmail.enable_command('download', list.get_selection().length > 0); + }); + + // check in contextmenu plugin exists and if so allow multiple message download + if (rcmail.contextmenu_disable_multi) + rcmail.contextmenu_disable_multi.splice($.inArray('#download', rcmail.contextmenu_disable_multi), 1); + } + }); + + rcmail.addEventListener('listupdate', function(props) { rcmail.enable_command('plugin.zipdownload.zip_folder', rcmail.env.messagecount > 0); } ); + rcmail.addEventListener('beforedownload', function(props) { rcmail_zipmessages(); } ); + } +}); \ No newline at end of file diff --git a/plugins/zipdownload/zipdownload.php b/plugins/zipdownload/zipdownload.php new file mode 100644 index 000000000..be4ece476 --- /dev/null +++ b/plugins/zipdownload/zipdownload.php @@ -0,0 +1,267 @@ + 520, 'type' => 'php', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => "php_zip extension is required for the zipdownload plugin"), true, false); + return; + } + + $rcmail = rcmail::get_instance(); + $this->charset = $rcmail->config->get('zipdownload_charset', RCMAIL_CHARSET); + + $this->load_config(); + $this->add_texts('localization'); + + if ($rcmail->config->get('zipdownload_attachments', 1) > -1 && ($rcmail->action == 'show' || $rcmail->action == 'preview')) + $this->add_hook('template_object_messageattachments', array($this, 'attachment_ziplink')); + + $this->register_action('plugin.zipdownload.zip_attachments', array($this, 'download_attachments')); + $this->register_action('plugin.zipdownload.zip_messages', array($this, 'download_selection')); + $this->register_action('plugin.zipdownload.zip_folder', array($this, 'download_folder')); + + if ($rcmail->config->get('zipdownload_folder', false) || $rcmail->config->get('zipdownload_selection', false)) { + $this->include_script('zipdownload.js'); + $this->api->output->set_env('zipdownload_selection', $rcmail->config->get('zipdownload_selection', false)); + + if ($rcmail->config->get('zipdownload_folder', false) && ($rcmail->action == '' || $rcmail->action == 'show')) { + $zipdownload = $this->api->output->button(array('command' => 'plugin.zipdownload.zip_folder', 'type' => 'link', 'classact' => 'active', 'content' => $this->gettext('downloadfolder'))); + $this->api->add_content(html::tag('li', array('class' => 'separator_above'), $zipdownload), 'mailboxoptions'); + } + } + } + + /** + * Place a link/button after attachments listing to trigger download + */ + public function attachment_ziplink($p) + { + $rcmail = rcmail::get_instance(); + + // only show the link if there is more than the configured number of attachments + if (substr_count($p['content'], ' $rcmail->config->get('zipdownload_attachments', 1)) { + $link = html::a(array( + 'href' => rcmail_url('plugin.zipdownload.zip_attachments', array('_mbox' => $rcmail->output->env['mailbox'], '_uid' => $rcmail->output->env['uid'])), + 'class' => 'button zipdownload', + ), + Q($this->gettext('downloadall')) + ); + + // append link to attachments list, slightly different in some skins + switch (rcube::get_instance()->config->get('skin')) { + case 'classic': + $p['content'] = str_replace('', html::tag('li', array('class' => 'zipdownload'), $link) . '', $p['content']); + break; + + default: + $p['content'] .= $link; + break; + } + + $this->include_stylesheet($this->local_skin_path() . '/zipdownload.css'); + } + + return $p; + } + + /** + * Handler for attachment download action + */ + public function download_attachments() + { + $rcmail = rcmail::get_instance(); + $imap = $rcmail->storage; + $temp_dir = $rcmail->config->get('temp_dir'); + $tmpfname = tempnam($temp_dir, 'zipdownload'); + $tempfiles = array($tmpfname); + $message = new rcube_message(get_input_value('_uid', RCUBE_INPUT_GET)); + + // open zip file + $zip = new ZipArchive(); + $zip->open($tmpfname, ZIPARCHIVE::OVERWRITE); + + foreach ($message->attachments as $part) { + $pid = $part->mime_id; + $part = $message->mime_parts[$pid]; + $disp_name = $this->_convert_filename($part->filename, $part->charset); + + if ($part->body) { + $orig_message_raw = $part->body; + $zip->addFromString($disp_name, $orig_message_raw); + } + else { + $tmpfn = tempnam($temp_dir, 'zipattach'); + $tmpfp = fopen($tmpfn, 'w'); + $imap->get_message_part($message->uid, $part->mime_id, $part, null, $tmpfp, true); + $tempfiles[] = $tmpfn; + fclose($tmpfp); + $zip->addFile($tmpfn, $disp_name); + } + + } + + $zip->close(); + + $filename = ($message->subject ? $message->subject : 'roundcube') . '.zip'; + $this->_deliver_zipfile($tmpfname, $filename); + + // delete temporary files from disk + foreach ($tempfiles as $tmpfn) + unlink($tmpfn); + + exit; + } + + /** + * Handler for message download action + */ + public function download_selection() + { + if (isset($_REQUEST['_uid'])) { + $uids = explode(",", get_input_value('_uid', RCUBE_INPUT_GPC)); + + if (sizeof($uids) > 0) + $this->_download_messages($uids); + } + } + + /** + * Handler for folder download action + */ + public function download_folder() + { + $imap = rcmail::get_instance()->storage; + $mbox_name = $imap->get_folder(); + + // initialize searching result if search_filter is used + if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL') { + $imap->search($mbox_name, $_SESSION['search_filter'], RCMAIL_CHARSET); + } + + // fetch message headers for all pages + $uids = array(); + if ($count = $imap->count($mbox_name, $imap->get_threading() ? 'THREADS' : 'ALL', FALSE)) { + for ($i = 0; ($i * $imap->get_pagesize()) <= $count; $i++) { + $a_headers = $imap->list_messages($mbox_name, ($i + 1)); + + foreach ($a_headers as $n => $header) { + if (empty($header)) + continue; + + array_push($uids, $header->uid); + } + } + } + + if (sizeof($uids) > 0) + $this->_download_messages($uids); + } + + /** + * Helper method to packs all the given messages into a zip archive + * + * @param array List of message UIDs to download + */ + private function _download_messages($uids) + { + $rcmail = rcmail::get_instance(); + $imap = $rcmail->storage; + $temp_dir = $rcmail->config->get('temp_dir'); + $tmpfname = tempnam($temp_dir, 'zipdownload'); + $tempfiles = array($tmpfname); + + // open zip file + $zip = new ZipArchive(); + $zip->open($tmpfname, ZIPARCHIVE::OVERWRITE); + + foreach ($uids as $key => $uid){ + $headers = $imap->get_message_headers($uid); + $subject = rcube_mime::decode_mime_string((string)$headers->subject); + $subject = $this->_convert_filename($subject); + $subject = substr($subject, 0, 16); + + if (isset($subject) && $subject !="") + $disp_name = $subject . ".eml"; + else + $disp_name = "message_rfc822.eml"; + + $disp_name = $uid . "_" . $disp_name; + + $tmpfn = tempnam($temp_dir, 'zipmessage'); + $tmpfp = fopen($tmpfn, 'w'); + $imap->get_raw_body($uid, $tmpfp); + $tempfiles[] = $tmpfn; + fclose($tmpfp); + $zip->addFile($tmpfn, $disp_name); + } + + $zip->close(); + + $this->_deliver_zipfile($tmpfname, $imap->get_folder() . '.zip'); + + // delete temporary files from disk + foreach ($tempfiles as $tmpfn) + unlink($tmpfn); + + exit; + } + + /** + * Helper method to send the zip archive to the browser + */ + private function _deliver_zipfile($tmpfname, $filename) + { + $browser = new rcube_browser; + send_nocacheing_headers(); + + if ($browser->ie && $browser->ver < 7) + $filename = rawurlencode(abbreviate_string($filename, 55)); + else if ($browser->ie) + $filename = rawurlencode($filename); + else + $filename = addcslashes($filename, '"'); + + // send download headers + header("Content-Type: application/octet-stream"); + if ($browser->ie) + header("Content-Type: application/force-download"); + + // don't kill the connection if download takes more than 30 sec. + @set_time_limit(0); + header("Content-Disposition: attachment; filename=\"". $filename ."\""); + header("Content-length: " . filesize($tmpfname)); + readfile($tmpfname); + } + + /** + * Helper function to convert filenames to the configured charset + */ + private function _convert_filename($str, $from = RCMAIL_CHARSET) + { + return strtr(rcube_charset_convert($str, $from, $this->charset), array(':'=>'', '/'=>'-')); + } +} + +?> \ No newline at end of file -- cgit v1.2.3 From bbbb2b1ce5b1dd71b5d2b9189f8e25dd596560b7 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Sun, 23 Sep 2012 22:47:56 +0200 Subject: Ignore plugin config.inc.php files --- .gitignore | 1 + plugins/zipdownload/config.inc.php | 21 --------------------- 2 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 plugins/zipdownload/config.inc.php diff --git a/.gitignore b/.gitignore index 589c34713..f55131f8c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ logs/* temp/* config/* +plugins/*/config.inc.php \ No newline at end of file diff --git a/plugins/zipdownload/config.inc.php b/plugins/zipdownload/config.inc.php deleted file mode 100644 index 1eb6f06cb..000000000 --- a/plugins/zipdownload/config.inc.php +++ /dev/null @@ -1,21 +0,0 @@ - \ No newline at end of file -- cgit v1.2.3 From 30f10bfe1685c18fa43f64603e1989355dc9b665 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 24 Sep 2012 10:03:34 +0200 Subject: Added request size limits detection and script corruption prevention (#1488648) --- plugins/managesieve/Changelog | 1 + plugins/managesieve/managesieve.php | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index a1dd7e0ca..c0428c4fc 100644 --- a/plugins/managesieve/Changelog +++ b/plugins/managesieve/Changelog @@ -1,6 +1,7 @@ - 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) - Change default port to 4190 (IANA-allocated), add port auto-detection (#1488713) +- Added request size limits detection and script corruption prevention (#1488648) * version 5.2 [2012-07-24] ----------------------------------------------------------- diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index 0ddeba542..7282ff2e0 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -530,9 +530,37 @@ class managesieve extends rcube_plugin // Init plugin and handle managesieve connection $error = $this->managesieve_start(); - // filters set add action - if (!empty($_POST['_newset'])) { + // get request size limits (#1488648) + $max_post = max(array( + ini_get('max_input_vars'), + ini_get('suhosin.request.max_vars'), + ini_get('suhosin.post.max_vars'), + )); + $max_depth = max(array( + ini_get('suhosin.request.max_array_depth'), + ini_get('suhosin.post.max_array_depth'), + )); + // check request size limit + if ($max_post && count($_POST, COUNT_RECURSIVE) >= $max_post) { + rcube::raise_error(array( + 'code' => 500, 'type' => 'php', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Request size limit exceeded (one of max_input_vars/suhosin.request.max_vars/suhosin.post.max_vars)" + ), true, false); + $this->rc->output->show_message('managesieve.filtersaveerror', 'error'); + } + // check request depth limits + else if ($max_depth && count($_POST['_header']) > $max_depth) { + rcube::raise_error(array( + 'code' => 500, 'type' => 'php', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Request size limit exceeded (one of suhosin.request.max_array_depth/suhosin.post.max_array_depth)" + ), true, false); + $this->rc->output->show_message('managesieve.filtersaveerror', 'error'); + } + // filters set add action + else if (!empty($_POST['_newset'])) { $name = get_input_value('_name', RCUBE_INPUT_POST, true); $copy = get_input_value('_copy', RCUBE_INPUT_POST, true); $from = get_input_value('_from', RCUBE_INPUT_POST); -- cgit v1.2.3 From 371a09b0db94cf558441f4182887f87b970bdc86 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Mon, 24 Sep 2012 11:35:46 +0200 Subject: Update changelog; mention zipdownload requirements in install notes --- CHANGELOG | 1 + INSTALL | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 61eced8f3..598eff9fb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Integrated zipdownload plugin to download all attachments (#1445509) - Fix HTML special characters handling in message list/header display (#1488523) - List related text/html part as attachment in plain text mode (#1488677) - Use IMAP BINARY (RFC3516) extension to fetch message/part bodies diff --git a/INSTALL b/INSTALL index f6d305ae5..30217686b 100644 --- a/INSTALL +++ b/INSTALL @@ -13,7 +13,7 @@ REQUIREMENTS * .htaccess support allowing overrides for DirectoryIndex * PHP Version 5.2.1 or greater including - PDO, PCRE, DOM, JSON, XML, Session, Sockets (required) - - libiconv (recommended) + - libiconv, zip (recommended) - mbstring, fileinfo, mcrypt (optional) * PEAR packages distributed with Roundcube or external: - Mail_Mime 1.8.1 or newer -- cgit v1.2.3 From 5f8406c76a1efdc50e5613a49ca10b86873fa436 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Mon, 24 Sep 2012 15:40:17 +0200 Subject: s/rcube/rcmail/ for compatibility with the 0.8 series --- plugins/zipdownload/zipdownload.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/zipdownload/zipdownload.php b/plugins/zipdownload/zipdownload.php index be4ece476..8bad9b341 100644 --- a/plugins/zipdownload/zipdownload.php +++ b/plugins/zipdownload/zipdownload.php @@ -22,7 +22,7 @@ class zipdownload extends rcube_plugin { // check requirements first if (!class_exists('ZipArchive', false)) { - rcube::raise_error(array( + rcmail::raise_error(array( 'code' => 520, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "php_zip extension is required for the zipdownload plugin"), true, false); @@ -70,7 +70,7 @@ class zipdownload extends rcube_plugin ); // append link to attachments list, slightly different in some skins - switch (rcube::get_instance()->config->get('skin')) { + switch (rcmail::get_instance()->config->get('skin')) { case 'classic': $p['content'] = str_replace('', html::tag('li', array('class' => 'zipdownload'), $link) . '', $p['content']); break; -- cgit v1.2.3 From dc8f292b215719506c2ab0abd8429f4c5ec5c0ed Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 26 Sep 2012 20:05:01 +0200 Subject: Make sure content (e.g. title) is not converted to plain text --- program/lib/html2text.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/program/lib/html2text.php b/program/lib/html2text.php index 28c5ae059..dd413e0d6 100644 --- a/program/lib/html2text.php +++ b/program/lib/html2text.php @@ -145,6 +145,7 @@ class html2text var $search = array( "/\r/", // Non-legal carriage return "/[\n\t]+/", // Newlines and tabs + '/]*>.*?<\/head>/i', // '/]*>.*?<\/script>/i', //