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 folders list scrolling on touch devices (#6706)
- Elastic: Fix non-working pretty selects in Chrome browser (#6705) - Elastic: Fix non-working pretty selects in Chrome browser (#6705)
- Managesieve: Fix bug where global includes were requested for vacation (#6716) - 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 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 bug where HTML messages with a xml:namespace tag were not rendered (#6697)
- Fix TinyMCE download location (#6694) - 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) - Fix bug where global includes were requested for vacation (#6716)
* version 9.2 [2018-11-08] * version 9.2 [2018-11-08]

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

@ -12,11 +12,13 @@ class Tokenizer extends PHPUnit_Framework_TestCase
{ {
return array( 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\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(0, '["test1","test2"]', '[["test1","test2"]]'),
array(1, '["test"]', '["test"]'), array(1, '["test"]', '["test"]'),
array(1, '"te\\"st"', '"te\\"st"'), array(1, '"te\\"st"', '"te\\"st"'),
array(0, 'test #comment', '["test"]'), array(0, 'test #comment', '["test"]'),
array(0, "text:\ntest\n.\ntext:\ntest\n.\n", '["test","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"'), array(1, '"\\a\\\\\\"a"', '"a\\\\\\"a"'),
); );
} }

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

@ -16,4 +16,3 @@ if header :matches "From" "*"
set "from" "${1}"; set "from" "${1}";
notify :importance "3" :message "${from}: ${subject}" "mailto:alm@example.com"; notify :importance "3" :message "${from}: ${subject}" "mailto:alm@example.com";
} }

Loading…
Cancel
Save