diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-06-01 20:04:07 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-06-01 20:04:07 -0400 |
commit | b0a31b168f41cf4b4e88b018747916992d9e5830 (patch) | |
tree | 00f7fdf88e097643d9d198aa128cde3ddbb2dd28 /app | |
parent | 92aba95959633eee824e2d19e12adc7921d31431 (diff) | |
parent | 6af3b6dfdbd2be9de3a3d670b89f694e4fcffd69 (diff) |
Merge pull-request #2280
Diffstat (limited to 'app')
-rw-r--r-- | app/Core/Filter/Lexer.php | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/Core/Filter/Lexer.php b/app/Core/Filter/Lexer.php index 8a7a68b1..fa5b8d2d 100644 --- a/app/Core/Filter/Lexer.php +++ b/app/Core/Filter/Lexer.php @@ -25,13 +25,13 @@ class Lexer * @var array */ private $tokenMap = array( - "/^(\s+)/" => 'T_WHITESPACE', + '/^(\s+)/' => 'T_WHITESPACE', '/^([<=>]{0,2}[0-9]{4}-[0-9]{2}-[0-9]{2})/' => 'T_STRING', - '/^([<=>]{1,2}\w+)/' => 'T_STRING', + '/^([<=>]{1,2}\w+)/u' => 'T_STRING', '/^([<=>]{1,2}".+")/' => 'T_STRING', '/^("(.+)")/' => 'T_STRING', - "/^(\w+)/" => 'T_STRING', - "/^(#\d+)/" => 'T_STRING', + '/^(\w+)/u' => 'T_STRING', + '/^(#\d+)/' => 'T_STRING', ); /** @@ -80,9 +80,10 @@ class Lexer { $tokens = array(); $this->offset = 0; + $input_length = mb_strlen($input, 'UTF-8'); - while (isset($input[$this->offset])) { - $result = $this->match(substr($input, $this->offset)); + while ($this->offset < $input_length) { + $result = $this->match(mb_substr($input, $this->offset, $input_length, 'UTF-8')); if ($result === false) { return array(); @@ -105,7 +106,7 @@ class Lexer { foreach ($this->tokenMap as $pattern => $name) { if (preg_match($pattern, $string, $matches)) { - $this->offset += strlen($matches[1]); + $this->offset += mb_strlen($matches[1], 'UTF-8'); return array( 'match' => str_replace('"', '', $matches[1]), |