From 302aff920c956d318f6f3262d7271ac5564dac78 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Wed, 13 Apr 2016 04:41:42 -0400 Subject: [PATCH] Small code improvement --- plugins/managesieve/lib/Roundcube/rcube_sieve_script.php | 44 ++++++++++++++++++++++++++------------------ 1 files changed, 26 insertions(+), 18 deletions(-) diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php index 51d9a20..c603dd5 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php @@ -966,25 +966,33 @@ $result = array(); for ($i=0, $len=count($tokens); $i<$len; $i++) { - if (!is_array($tokens[$i]) && preg_match('/^:comparator$/i', $tokens[$i])) { - $test['comparator'] = $tokens[++$i]; - } - else if (!is_array($tokens[$i]) && preg_match('/^:(count|value)$/i', $tokens[$i])) { - $test['type'] = strtolower(substr($tokens[$i], 1)) . '-' . $tokens[++$i]; - } - else if (!is_array($tokens[$i]) && preg_match('/^:(is|contains|matches|regex)$/i', $tokens[$i])) { - $test['type'] = strtolower(substr($tokens[$i], 1)); - } - else if (!is_array($tokens[$i]) && preg_match('/^:index$/i', $tokens[$i])) { - $test['index'] = intval($tokens[++$i]); - if ($tokens[$i+1] && preg_match('/^:last$/i', $tokens[$i+1])) { - $test['last'] = true; - $i++; + if (!is_array($tokens[$i]) && $tokens[$i][0] == ':') { + if (preg_match('/^:comparator$/i', $tokens[$i])) { + $test['comparator'] = $tokens[++$i]; + continue; } - } - else { - $result[] = $tokens[$i]; - } + + if (preg_match('/^:(count|value)$/i', $tokens[$i])) { + $test['type'] = strtolower(substr($tokens[$i], 1)) . '-' . $tokens[++$i]; + continue; + } + + if (preg_match('/^:(is|contains|matches|regex)$/i', $tokens[$i])) { + $test['type'] = strtolower(substr($tokens[$i], 1)); + continue; + } + + if (preg_match('/^:index$/i', $tokens[$i])) { + $test['index'] = intval($tokens[++$i]); + if ($tokens[$i+1] && preg_match('/^:last$/i', $tokens[$i+1])) { + $test['last'] = true; + $i++; + } + continue; + } + } + + $result[] = $tokens[$i]; } $tokens = $result; -- Gitblit v1.9.1