|
|
@ -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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|