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 /plugins/managesieve/lib | |
| 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
Diffstat (limited to 'plugins/managesieve/lib')
| -rw-r--r-- | plugins/managesieve/lib/rcube_sieve_script.php | 15 |
1 files changed, 9 insertions, 6 deletions
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 . '"'; } } |
