diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-02-13 18:04:12 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-02-13 18:04:12 +0000 |
| commit | 5ab43401cc255bc6ce74ed1643abc9b5cc9b3979 (patch) | |
| tree | ec3248d4ffc73c496a635cb9e429244e3ba40b34 | |
| parent | 72c87ab45962cb5aedb26ec251ce09c74498b540 (diff) | |
- Fix escaping of backslash character in quoted strings (#1487780)
git-svn-id: https://svn.roundcube.net/trunk@4536 208e9e7b-5314-0410-a742-e7e81cd9613c
| -rw-r--r-- | plugins/managesieve/Changelog | 3 | ||||
| -rw-r--r-- | plugins/managesieve/lib/rcube_sieve_script.php | 15 | ||||
| -rw-r--r-- | plugins/managesieve/managesieve.php | 11 | ||||
| -rw-r--r-- | plugins/managesieve/tests/parser.phpt | 15 |
4 files changed, 30 insertions, 14 deletions
diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index 298507aba..40b242f7e 100644 --- a/plugins/managesieve/Changelog +++ b/plugins/managesieve/Changelog @@ -1,4 +1,5 @@ -- Fix fileinto target is always INBOX (#1487776) +- Fix fileinto target is always INBOX (#1487776) +- Fix escaping of backslash character in quoted strings (#1487780) * version 4.0 [2011-02-10] ----------------------------------------------------------- diff --git a/plugins/managesieve/lib/rcube_sieve_script.php b/plugins/managesieve/lib/rcube_sieve_script.php index 1b7c8faaf..6aa4f5542 100644 --- a/plugins/managesieve/lib/rcube_sieve_script.php +++ b/plugins/managesieve/lib/rcube_sieve_script.php @@ -216,8 +216,11 @@ class rcube_sieve_script case 'addflag': case 'setflag': case 'removeflag': - $imapflags = strtolower($action['mode']) == 'imap4flags' ? 'imap4flags' : 'imapflags'; - array_push($exts, $imapflags); + if (!empty($action['mode']) && strtolower($action['mode']) == 'imap4flags') + array_push($exts, 'imap4flags'); + else + array_push($exts, 'imapflags'); + $script .= "\t".$action['type']." " . self::escape_string($action['target']) . ";\n"; break; @@ -546,14 +549,14 @@ class rcube_sieve_script } // multi-line string - if (preg_match('/[\r\n\0]/', $str)) { + if (preg_match('/[\r\n\0]/', $str) || strlen($str) > 1024) { return sprintf("text:\n%s\n.\n", self::escape_multiline_string($str)); } // quoted-string else { - $replace['/"/'] = '\\"'; - return '"'. preg_replace(array_keys($replace), array_values($replace), - $str) . '"'; + $replace = array('\\' => '\\\\', '"' => '\\"'); + $str = str_replace(array_keys($replace), array_values($replace), $str); + return '"' . $str . '"'; } } diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index 9cbba482a..1b44562f8 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -1073,13 +1073,14 @@ class managesieve extends rcube_plugin // flags $flags = array( - 'read' => '\\\\Seen', - 'answered' => '\\\\Answered', - 'flagged' => '\\\\Flagged', - 'deleted' => '\\\\Deleted', - 'draft' => '\\\\Draft', + 'read' => '\\Seen', + 'answered' => '\\Answered', + 'flagged' => '\\Flagged', + 'deleted' => '\\Deleted', + 'draft' => '\\Draft', ); $flags_target = (array)$action['target']; + $out .= '<div id="action_flags' .$id.'" style="display:' . (preg_match('/^(set|add|remove)flag$/', $action['type']) ? 'inline' : 'none') . '"' . $this->error_class($id, 'action', 'flags', 'action_flags') . '>'; diff --git a/plugins/managesieve/tests/parser.phpt b/plugins/managesieve/tests/parser.phpt index 519f8026b..d70353459 100644 --- a/plugins/managesieve/tests/parser.phpt +++ b/plugins/managesieve/tests/parser.phpt @@ -6,7 +6,7 @@ Main test of script parser include '../lib/rcube_sieve_script.php'; $txt = ' -require ["fileinto","vacation","reject","relational","comparator-i;ascii-numeric"]; +require ["fileinto","vacation","reject","relational","comparator-i;ascii-numeric","imapflags"]; # rule:[spam] if anyof (header :contains "X-DSPAM-Result" "Spam") { @@ -49,6 +49,11 @@ if size :over 5000K { # rule:[redirect] if header :value "ge" :comparator "i;ascii-numeric" ["X-Spam-score"] ["14"] {redirect "test@test.tld";} +# rule:[imapflags] +if header :matches "Subject" "^Test$" { + setflag "\\\\Seen"; + addflag ["\\\\Answered","\\\\Deleted"]; +} '; $s = new rcube_sieve_script($txt); @@ -56,7 +61,7 @@ echo $s->as_text(); ?> --EXPECT-- -require ["fileinto","vacation","reject","relational","comparator-i;ascii-numeric"]; +require ["fileinto","vacation","reject","relational","comparator-i;ascii-numeric","imapflags"]; # rule:[spam] if header :contains "X-DSPAM-Result" "Spam" { @@ -101,3 +106,9 @@ if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-score" "14" { redirect "test@test.tld"; } +# rule:[imapflags] +if header :matches "Subject" "^Test$" +{ + setflag "\\Seen"; + addflag ["\\Answered","\\Deleted"]; +} |
