diff options
author | alecpl <alec@alec.pl> | 2010-12-28 07:17:32 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2010-12-28 07:17:32 +0000 |
commit | f7221df5c5082408591a779bb3616b358d496943 (patch) | |
tree | 4533f58647a134184a048da78f1a59f26e57e514 /program/include/rcube_imap_generic.php | |
parent | a63b36a44b07abc89e3dd442fc075c2e7ca9d78e (diff) |
- Fix for ANNOTATEMORE drafts below 08 version (use quoted parameters)
Diffstat (limited to 'program/include/rcube_imap_generic.php')
-rw-r--r-- | program/include/rcube_imap_generic.php | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php index f1b704cde..8b04a6b93 100644 --- a/program/include/rcube_imap_generic.php +++ b/program/include/rcube_imap_generic.php @@ -2881,8 +2881,9 @@ class rcube_imap_generic $value = sprintf("{%d}\r\n%s", strlen($value), $value); } + // ANNOTATEMORE drafts before version 08 require quoted parameters $entries[] = sprintf('%s (%s %s)', - $this->escape($name), $this->escape($attr), $value); + $this->escape($name, true), $this->escape($attr, true), $value); } $entries = implode(' ', $entries); @@ -2932,8 +2933,9 @@ class rcube_imap_generic $entries = array($entries); } // create entries string + // ANNOTATEMORE drafts before version 08 require quoted parameters foreach ($entries as $idx => $name) { - $entries[$idx] = $this->escape($name); + $entries[$idx] = $this->escape($name, true); } $entries = '(' . implode(' ', $entries) . ')'; @@ -2942,7 +2944,7 @@ class rcube_imap_generic } // create entries string foreach ($attribs as $idx => $name) { - $attribs[$idx] = $this->escape($name); + $attribs[$idx] = $this->escape($name, true); } $attribs = '(' . implode(' ', $attribs) . ')'; @@ -3237,12 +3239,13 @@ class rcube_imap_generic /** * Escapes a string when it contains special characters (RFC3501) * - * @param string $string IMAP string + * @param string $string IMAP string + * @param boolean $force_quotes Forces string quoting * * @return string Escaped string * @todo String literals, lists */ - static function escape($string) + static function escape($string, $force_quotes=false) { if ($string === null) { return 'NIL'; @@ -3250,7 +3253,9 @@ class rcube_imap_generic else if ($string === '') { return '""'; } - else if (preg_match('/([\x00-\x20\x28-\x29\x7B\x25\x2A\x22\x5C\x5D\x7F]+)/', $string)) { + else if ($force_quotes || + preg_match('/([\x00-\x20\x28-\x29\x7B\x25\x2A\x22\x5C\x5D\x7F]+)/', $string) + ) { // string: special chars: SP, CTL, (, ), {, %, *, ", \, ] return '"' . strtr($string, array('"'=>'\\"', '\\' => '\\\\')) . '"'; } |