Managesieve: Use RFC-compliant line endings, CRLF instead of LF (#6686)

pull/6724/head
Aleksander Machniak 6 years ago
parent d8470c6c2b
commit ccb70116f1

@ -16,6 +16,7 @@ CHANGELOG Roundcube Webmail
- Elastic: Fix folders list scrolling on touch devices (#6706)
- Elastic: Fix non-working pretty selects in Chrome browser (#6705)
- Managesieve: Fix bug where global includes were requested for vacation (#6716)
- Managesieve: Use RFC-compliant line endings, CRLF instead of LF (#6686)
- Fix bug in HTML parser that could cause missing text fragments when there was no head/body tag (#6713)
- Fix bug where HTML messages with a xml:namespace tag were not rendered (#6697)
- Fix TinyMCE download location (#6694)

@ -1,3 +1,4 @@
- Use RFC-compliant line endings, CRLF instead of LF (#6686)
- Fix bug where global includes were requested for vacation (#6716)
* version 9.2 [2018-11-08]

@ -196,14 +196,14 @@ class rcube_sieve_script
foreach ($this->vars as $var) {
if (empty($has_vars)) {
// 'variables' extension not supported, put vars in comments
$output .= sprintf("# %s %s\n", $var['name'], $var['value']);
$output .= sprintf("# %s %s\r\n", $var['name'], $var['value']);
}
else {
$output .= 'set ';
foreach (array_diff(array_keys($var), array('name', 'value')) as $opt) {
$output .= ":$opt ";
}
$output .= self::escape_string($var['name']) . ' ' . self::escape_string($var['value']) . ";\n";
$output .= self::escape_string($var['name']) . ' ' . self::escape_string($var['value']) . ";\r\n";
}
}
}
@ -219,7 +219,7 @@ class rcube_sieve_script
// header
if (!empty($rule['name']) && strlen($rule['name'])) {
$script .= '# rule:[' . $rule['name'] . "]\n";
$script .= '# rule:[' . $rule['name'] . "]\r\n";
}
// constraints expressions
@ -379,7 +379,7 @@ class rcube_sieve_script
else {
$script .= $tests_str;
}
$script .= "\n{\n";
$script .= "\r\n{\r\n";
}
// action(s)
@ -548,13 +548,13 @@ class rcube_sieve_script
if ($action_script) {
$script .= !empty($tests) ? "\t" : '';
$script .= $action_script . ";\n";
$script .= $action_script . ";\r\n";
}
}
}
if ($script) {
$output .= $script . (!empty($tests) ? "}\n" : '');
$output .= $script . (!empty($tests) ? "}\r\n" : '');
$idx++;
}
}
@ -569,11 +569,11 @@ class rcube_sieve_script
sort($exts); // for convenience use always the same order
$output = 'require ["' . implode('","', $exts) . "\"];\n" . $output;
$output = 'require ["' . implode('","', $exts) . "\"];\r\n" . $output;
}
if (!empty($this->prefix)) {
$output = $this->prefix . "\n\n" . $output;
$output = $this->prefix . "\r\n\r\n" . $output;
}
return $output;
@ -678,7 +678,7 @@ class rcube_sieve_script
}
if (!empty($prefix)) {
$this->prefix = trim($prefix);
$this->prefix = trim(preg_replace('/\r?\n/', "\r\n", $prefix));
}
}
@ -1203,7 +1203,7 @@ class rcube_sieve_script
// multi-line string
if (preg_match('/[\r\n\0]/', $str)) {
return sprintf("text:\n%s\n.\n", self::escape_multiline_string($str));
return sprintf("text:\r\n%s\r\n.\r\n", self::escape_multiline_string($str));
}
// quoted-string
else {
@ -1394,7 +1394,7 @@ class rcube_sieve_script
// remove dot-stuffing
$text = str_replace("\n..", "\n.", $text);
$result[] = $text;
$result[] = rtrim($text, "\r\n");
$position++;
}
}

@ -12,11 +12,13 @@ class Tokenizer extends PHPUnit_Framework_TestCase
{
return array(
array(1, "text: #test\nThis is test ; message;\nMulti line\n.\n;\n", '"This is test ; message;\nMulti line"'),
array(1, "text: #test\r\nThis is test ; message;\nMulti line\r\n.\r\n;", '"This is test ; message;\nMulti line"'),
array(0, '["test1","test2"]', '[["test1","test2"]]'),
array(1, '["test"]', '["test"]'),
array(1, '"te\\"st"', '"te\\"st"'),
array(0, 'test #comment', '["test"]'),
array(0, "text:\ntest\n.\ntext:\ntest\n.\n", '["test","test"]'),
array(0, "text:\r\ntest\r\n.\r\ntext:\r\ntest\r\n.\r\n", '["test","test"]'),
array(1, '"\\a\\\\\\"a"', '"a\\\\\\"a"'),
);
}

@ -63,4 +63,3 @@ class Managesieve_Vacation extends PHPUnit_Framework_TestCase
$this->assertSame('05 Mar 2014', $result['to']);
}
}

@ -1,58 +1,58 @@
require ["envelope","fileinto","reject"];
# rule:[spam]
if header :contains "X-DSPAM-Result" "Spam"
{
fileinto "Spam";
stop;
}
# rule:[test1]
if header :contains ["From","To"] "test@domain.tld"
{
discard;
stop;
}
# rule:[test2]
if anyof (not header :contains :comparator "i;octet" "Subject" "[test]", header :contains "Subject" "[test2]")
{
fileinto "test";
stop;
}
# rule:[comments]
if true
{
stop;
}
# rule:[reject]
if size :over 5000K
{
reject "Message over 5MB size limit. Please contact me before sending this.";
}
# rule:[false]
if false # size :over 5000K
{
stop;
}
# rule:[true]
if true
{
stop;
}
fileinto "Test";
# rule:[address test]
if address :is "From" "nagios@domain.tld"
{
fileinto "domain.tld";
stop;
}
# rule:[envelope test]
if envelope :domain :is "From" "domain.tld"
{
fileinto "domain.tld";
stop;
}
# rule:[do not wrap long lines]
if envelope :domain :is "From" "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
{
fileinto "domain.tld";
stop;
}
require ["envelope","fileinto","reject"];
# rule:[spam]
if header :contains "X-DSPAM-Result" "Spam"
{
fileinto "Spam";
stop;
}
# rule:[test1]
if header :contains ["From","To"] "test@domain.tld"
{
discard;
stop;
}
# rule:[test2]
if anyof (not header :contains :comparator "i;octet" "Subject" "[test]", header :contains "Subject" "[test2]")
{
fileinto "test";
stop;
}
# rule:[comments]
if true
{
stop;
}
# rule:[reject]
if size :over 5000K
{
reject "Message over 5MB size limit. Please contact me before sending this.";
}
# rule:[false]
if false # size :over 5000K
{
stop;
}
# rule:[true]
if true
{
stop;
}
fileinto "Test";
# rule:[address test]
if address :is "From" "nagios@domain.tld"
{
fileinto "domain.tld";
stop;
}
# rule:[envelope test]
if envelope :domain :is "From" "domain.tld"
{
fileinto "domain.tld";
stop;
}
# rule:[do not wrap long lines]
if envelope :domain :is "From" "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
{
fileinto "domain.tld";
stop;
}

@ -1,17 +1,17 @@
require ["body","fileinto"];
if body :raw :contains "MAKE MONEY FAST"
{
stop;
}
if body :content "text" :contains ["missile","coordinates"]
{
fileinto "secrets";
}
if body :content "audio/mp3" :contains ""
{
fileinto "jukebox";
}
if body :text :contains "project schedule"
{
fileinto "project/schedule";
}
require ["body","fileinto"];
if body :raw :contains "MAKE MONEY FAST"
{
stop;
}
if body :content "text" :contains ["missile","coordinates"]
{
fileinto "secrets";
}
if body :content "audio/mp3" :contains ""
{
fileinto "jukebox";
}
if body :text :contains "project schedule"
{
fileinto "project/schedule";
}

@ -1,10 +1,10 @@
require ["envelope","fileinto","imap4flags","subaddress"];
if envelope :detail "to" "addressextension"
{
setflag "\\Flagged";
}
if header :is "X-Spam-Flag" "YES"
{
fileinto "Junk";
stop;
}
require ["envelope","fileinto","imap4flags","subaddress"];
if envelope :detail "to" "addressextension"
{
setflag "\\Flagged";
}
if header :is "X-Spam-Flag" "YES"
{
fileinto "Junk";
stop;
}

@ -1,21 +1,21 @@
require ["comparator-i;ascii-numeric","date","fileinto","relational"];
# rule:[date]
if allof (date :originalzone :value "ge" :comparator "i;ascii-numeric" "date" "hour" "09")
{
fileinto "urgent";
}
# rule:[date-weekday]
if date :is "received" "weekday" "0"
{
fileinto "weekend";
}
# rule:[date-zone]
if date :zone "-0500" :value "gt" :comparator "i;ascii-numeric" "received" "iso8601" "2007-02-26T09:00:00-05:00"
{
stop;
}
# rule:[currentdate]
if anyof (currentdate :is "weekday" "0", currentdate :value "lt" :comparator "i;ascii-numeric" "hour" "09", currentdate :value "ge" :comparator "i;ascii-numeric" "date" "2007-06-30")
{
stop;
}
require ["comparator-i;ascii-numeric","date","fileinto","relational"];
# rule:[date]
if allof (date :originalzone :value "ge" :comparator "i;ascii-numeric" "date" "hour" "09")
{
fileinto "urgent";
}
# rule:[date-weekday]
if date :is "received" "weekday" "0"
{
fileinto "weekend";
}
# rule:[date-zone]
if date :zone "-0500" :value "gt" :comparator "i;ascii-numeric" "received" "iso8601" "2007-02-26T09:00:00-05:00"
{
stop;
}
# rule:[currentdate]
if anyof (currentdate :is "weekday" "0", currentdate :value "lt" :comparator "i;ascii-numeric" "hour" "09", currentdate :value "ge" :comparator "i;ascii-numeric" "date" "2007-06-30")
{
stop;
}

@ -1,16 +1,16 @@
require ["duplicate","fileinto"];
# rule:[test-duplicate]
if duplicate
{
fileinto "urgent";
}
# rule:[test-duplicate-2]
if allof (duplicate :handle "support" :header "X-Ticket-ID", header :contains "subject" "fileserver")
{
fileinto "test";
}
# rule:[test-duplicate-3]
if not duplicate :uniqueid "test" :seconds 1800
{
discard;
}
require ["duplicate","fileinto"];
# rule:[test-duplicate]
if duplicate
{
fileinto "urgent";
}
# rule:[test-duplicate-2]
if allof (duplicate :handle "support" :header "X-Ticket-ID", header :contains "subject" "fileserver")
{
fileinto "test";
}
# rule:[test-duplicate-3]
if not duplicate :uniqueid "test" :seconds 1800
{
discard;
}

@ -1,36 +1,36 @@
require ["editheader"];
# rule:[test-addheader1]
if true
{
addheader "X-Sieve-Filtered" "<test@test.com>";
}
# rule:[test-addheader2]
if not header :contains "X-Sieve-Filtered" "<test@test.com>"
{
addheader :last "X-Sieve-Filtered" "<test@test.com>";
}
# rule:[test-deleteheader1]
if true
{
deleteheader :index 1 :contains "Delivered-To" ["bob@example.com","test@test.com"];
}
# rule:[test-deleteheader2]
if true
{
deleteheader :index 2 :last :contains :comparator "i;octet" "Delivered-To" "test@test.com";
}
# rule:[test-deleteheader3]
if true
{
deleteheader "Delivered-To";
}
# rule:[test-deleteheader4]
if true
{
deleteheader :index 3 :last :contains "Delivered-To";
}
# rule:[test-deleteheader5]
if true
{
deleteheader "Delivered-To" "test";
}
require ["editheader"];
# rule:[test-addheader1]
if true
{
addheader "X-Sieve-Filtered" "<test@test.com>";
}
# rule:[test-addheader2]
if not header :contains "X-Sieve-Filtered" "<test@test.com>"
{
addheader :last "X-Sieve-Filtered" "<test@test.com>";
}
# rule:[test-deleteheader1]
if true
{
deleteheader :index 1 :contains "Delivered-To" ["bob@example.com","test@test.com"];
}
# rule:[test-deleteheader2]
if true
{
deleteheader :index 2 :last :contains :comparator "i;octet" "Delivered-To" "test@test.com";
}
# rule:[test-deleteheader3]
if true
{
deleteheader "Delivered-To";
}
# rule:[test-deleteheader4]
if true
{
deleteheader :index 3 :last :contains "Delivered-To";
}
# rule:[test-deleteheader5]
if true
{
deleteheader "Delivered-To" "test";
}

@ -1,19 +1,18 @@
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";
}
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";
}

@ -1,18 +1,18 @@
require ["enotify","envelope","variables"];
# rule:[from]
if envelope :matches "from" "*"
{
set "env_from" " [really: ${1}]";
}
# rule:[subject]
if header :matches "Subject" "*"
{
set "subject" "${1}";
}
# rule:[from notify]
if address :matches "from" "*"
{
set "from_addr" "${1}";
notify :message "${from_addr}${env_from}: ${subject}" "mailto:alm@example.com";
}
require ["enotify","envelope","variables"];
# rule:[from]
if envelope :matches "from" "*"
{
set "env_from" " [really: ${1}]";
}
# rule:[subject]
if header :matches "Subject" "*"
{
set "subject" "${1}";
}
# rule:[from notify]
if address :matches "from" "*"
{
set "from_addr" "${1}";
notify :message "${from_addr}${env_from}: ${subject}" "mailto:alm@example.com";
}

@ -1,7 +1,7 @@
require ["imap4flags"];
# rule:[imapflags]
if header :matches "Subject" "^Test$"
{
setflag "\\Seen";
addflag ["\\Answered","\\Deleted"];
}
require ["imap4flags"];
# rule:[imapflags]
if header :matches "Subject" "^Test$"
{
setflag "\\Seen";
addflag ["\\Answered","\\Deleted"];
}

@ -1,7 +1,7 @@
require ["include"];
include "script.sieve";
# rule:[two]
if true
{
include :optional "second.sieve";
}
require ["include"];
include "script.sieve";
# rule:[two]
if true
{
include :optional "second.sieve";
}

@ -1,24 +1,24 @@
require ["comparator-i;ascii-numeric","date","fileinto","index","relational"];
# rule:[index-header1]
if header :index 1 :last :contains "X-DSPAM-Result" "Spam"
{
fileinto "Spam";
stop;
}
# rule:[index-header2]
if header :index 2 :contains ["From","To"] "test@domain.tld"
{
discard;
stop;
}
# rule:[index-address]
if address :index 1 :is "From" "nagios@domain.tld"
{
fileinto "domain.tld";
stop;
}
# rule:[index-date]
if date :index 1 :last :zone "-0500" :value "gt" :comparator "i;ascii-numeric" "received" "iso8601" "2007-02-26T09:00:00-05:00"
{
stop;
}
require ["comparator-i;ascii-numeric","date","fileinto","index","relational"];
# rule:[index-header1]
if header :index 1 :last :contains "X-DSPAM-Result" "Spam"
{
fileinto "Spam";
stop;
}
# rule:[index-header2]
if header :index 2 :contains ["From","To"] "test@domain.tld"
{
discard;
stop;
}
# rule:[index-address]
if address :index 1 :is "From" "nagios@domain.tld"
{
fileinto "domain.tld";
stop;
}
# rule:[index-date]
if date :index 1 :last :zone "-0500" :value "gt" :comparator "i;ascii-numeric" "received" "iso8601" "2007-02-26T09:00:00-05:00"
{
stop;
}

@ -1,3 +1,3 @@
require ["variables"];
set "EDITOR" "Roundcube";
set "EDITOR_VERSION" "123";
require ["variables"];
set "EDITOR" "Roundcube";
set "EDITOR_VERSION" "123";

@ -1,10 +1,10 @@
# Sieve Filter
# Erzeugt von Ingo (http://www.horde.org/ingo/) (30.09.2016, 16:02)
# Nested rules aren't supported and will be ignored (#5540)
# rule:[Ausgeschlossene Adressen]
if address :is ["From","Sender","Resent-From"] "noreply@example.org"
{
discard;
stop;
}
# Sieve Filter
# Erzeugt von Ingo (http://www.horde.org/ingo/) (30.09.2016, 16:02)
# Nested rules aren't supported and will be ignored (#5540)
# rule:[Ausgeschlossene Adressen]
if address :is ["From","Sender","Resent-From"] "noreply@example.org"
{
discard;
stop;
}

@ -1,18 +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 :method "mailto" :options "test@example.org" :message "${from}: ${subject}";
}
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 :method "mailto" :options "test@example.org" :message "${from}: ${subject}";
}

@ -1,17 +1,17 @@
require ["envelope","notify","variables"];
# rule:[from]
if envelope :matches "from" "*"
{
set "env_from" " [really: ${1}]";
}
# rule:[subject]
if header :matches "Subject" "*"
{
set "subject" "${1}";
}
# rule:[from notify]
if address :matches "from" "*"
{
set "from_addr" "${1}";
notify :method "sms" :options "1234567890" :message "${from_addr}${env_from}: ${subject}";
}
require ["envelope","notify","variables"];
# rule:[from]
if envelope :matches "from" "*"
{
set "env_from" " [really: ${1}]";
}
# rule:[subject]
if header :matches "Subject" "*"
{
set "subject" "${1}";
}
# rule:[from notify]
if address :matches "from" "*"
{
set "from_addr" "${1}";
notify :method "sms" :options "1234567890" :message "${from_addr}${env_from}: ${subject}";
}

@ -1,5 +1,5 @@
# this is a comment
# and the second line
require ["variables"];
set "b" "c";
# this is a comment
# and the second line
require ["variables"];
set "b" "c";

@ -1,6 +1,6 @@
require ["comparator-i;ascii-numeric","relational"];
# rule:[redirect]
if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-score" "14"
{
redirect "test@test.tld";
}
require ["comparator-i;ascii-numeric","relational"];
# rule:[redirect]
if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-score" "14"
{
redirect "test@test.tld";
}

@ -1,11 +1,11 @@
require ["envelope","fileinto","subaddress"];
if envelope :user "To" "postmaster"
{
fileinto "postmaster";
stop;
}
if envelope :detail :is "To" "mta-filters"
{
fileinto "mta-filters";
stop;
}
require ["envelope","fileinto","subaddress"];
if envelope :user "To" "postmaster"
{
fileinto "postmaster";
stop;
}
if envelope :detail :is "To" "mta-filters"
{
fileinto "mta-filters";
stop;
}

@ -1,14 +1,14 @@
require ["vacation"];
# rule:[test-vacation]
if header :contains "Subject" "vacation"
{
vacation :days 1 text:
# test
test test /* test */
..
..test
test
.
;
stop;
}
require ["vacation"];
# rule:[test-vacation]
if header :contains "Subject" "vacation"
{
vacation :days 1 text:
# test
test test /* test */
..
..test
test
.
;
stop;
}

@ -1,12 +1,12 @@
require ["vacation-seconds"];
# rule:[test-vacation]
if header :contains "Subject" "vacation"
{
vacation :seconds 0 text:
# test
test test /* test */
test
.
;
stop;
}
require ["vacation-seconds"];
# rule:[test-vacation]
if header :contains "Subject" "vacation"
{
vacation :seconds 0 text:
# test
test test /* test */
test
.
;
stop;
}

@ -1,24 +1,24 @@
require ["variables"];
set "honorific" "Mr";
set "vacation" text:
Dear ${HONORIFIC} ${last_name},
I am out, please leave a message after the meep.
.
;
set :length "b" "${a}";
set :lower "b" "${a}";
set :upperfirst "b" "${a}";
set :upperfirst :lower "b" "${a}";
set :quotewildcard "b" "Rock*";
if string :matches " ${state} " "* pending *"
{
set "test1" "*";
}
if string ["aaa","bbb"] ["aaa","bbb"]
{
set "test2" "*";
}
if string :is :comparator "i;octet" "bbb" "bbb"
{
set "test3" "*";
}
require ["variables"];
set "honorific" "Mr";
set "vacation" text:
Dear ${HONORIFIC} ${last_name},
I am out, please leave a message after the meep.
.
;
set :length "b" "${a}";
set :lower "b" "${a}";
set :upperfirst "b" "${a}";
set :upperfirst :lower "b" "${a}";
set :quotewildcard "b" "Rock*";
if string :matches " ${state} " "* pending *"
{
set "test1" "*";
}
if string ["aaa","bbb"] ["aaa","bbb"]
{
set "test2" "*";
}
if string :is :comparator "i;octet" "bbb" "bbb"
{
set "test3" "*";
}

Loading…
Cancel
Save