From e2ff7985dbcf2ff56644cae9e8d14a06ce4242c3 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Wed, 13 Apr 2016 04:27:35 -0400 Subject: [PATCH] Small optimization in sieve script parser --- plugins/managesieve/lib/Roundcube/rcube_sieve_script.php | 14 ++++---------- 1 files changed, 4 insertions(+), 10 deletions(-) diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php index 0b11de1..51d9a20 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php @@ -1090,6 +1090,7 @@ { $result = array(); $length = strlen($str); + $mask = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:_'; // remove spaces from the beginning of the string while ($position < $length && (!$num || $num === true || count($result) < $num)) { @@ -1175,18 +1176,11 @@ if ($position == $length) { break 2; } - if ($length - $position < 2) { - $result[] = substr($str, $position); - $position = $length; - break; - } // tag/identifier/number - if (preg_match('/[a-zA-Z0-9:_]+/', $str, $m, PREG_OFFSET_CAPTURE, $position) - && $m[0][1] == $position - ) { - $atom = $m[0][0]; - $position += strlen($atom); + if ($len = strspn($str, $mask, $position)) { + $atom = substr($str, $position, $len); + $position += $len; if ($atom != 'text:') { $result[] = $atom; -- Gitblit v1.9.1