Aleksander Machniak
2016-05-22 0344b168276f80189e2254c75a762aff5b517b6b
plugins/managesieve/lib/Roundcube/rcube_sieve_script.php
@@ -24,21 +24,22 @@
{
    public $content = array();      // script rules array
    private $vars = array();        // "global" variables
    private $prefix = '';           // script header (comments)
    private $supported = array(     // Sieve extensions supported by class
    private $vars      = array();   // "global" variables
    private $prefix    = '';        // script header (comments)
    private $supported = array(     // supported Sieve extensions:
        'body',                     // RFC5173
        'copy',                     // RFC3894
        'date',                     // RFC5260
        'duplicate',                // RFC7352
        'enotify',                  // RFC5435
        'envelope',                 // RFC5228
        'ereject',                  // RFC5429
        'fileinto',                 // RFC5228
        'imapflags',                // draft-melnikov-sieve-imapflags-06
        'imap4flags',               // RFC5232
        'include',                  // draft-ietf-sieve-include-12
        'include',                  // RFC6609
        'index',                    // RFC5260
        'notify',                   // draft-martin-sieve-notify-01,
        'notify',                   // RFC5435
        'regex',                    // draft-ietf-sieve-regex-01
        'reject',                   // RFC5429
        'relational',               // RFC3431
@@ -317,7 +318,29 @@
                        $tests[$i] .= ' ' . self::escape_string($test['arg']);
                        break;
                    case 'duplicate':
                        array_push($exts, 'duplicate');
                        $tests[$i] .= ($test['not'] ? 'not ' : '') . $test['test'];
                        $tokens = array('handle', 'uniqueid', 'header');
                        foreach ($tokens as $token)
                            if ($test[$token] !== null && $test[$token] !== '') {
                                $tests[$i] .= " :$token " . self::escape_string($test[$token]);
                            }
                        if (!empty($test['seconds'])) {
                            $tests[$i] .= ' :seconds ' . intval($test['seconds']);
                        }
                        if (!empty($test['last'])) {
                            $tests[$i] .= ' :last';
                        }
                        break;
                    }
                    $i++;
                }
            }
@@ -749,6 +772,23 @@
                $tests[] = $test;
                break;
            case 'duplicate':
                $test = array('test' => $token, 'not' => $not);
                for ($i=0, $len=count($tokens); $i<$len; $i++) {
                    if (!is_array($tokens[$i])) {
                        if (preg_match('/^:(handle|header|uniqueid|seconds)$/i', $tokens[$i], $m)) {
                            $test[strtolower($m[1])] = $tokens[++$i];
                        }
                        else if (preg_match('/^:last$/i', $tokens[$i])) {
                            $test['last'] = true;
                        }
                    }
                }
                $tests[] = $test;
                break;
            case 'exists':
                $tests[] = array('test' => 'exists', 'not' => $not,
                    'arg'  => array_pop($tokens));