diff options
author | Michal Čihař <michal@cihar.com> | 2017-07-12 14:02:13 +0200 |
---|---|---|
committer | Michal Čihař <michal@cihar.com> | 2017-07-12 14:02:59 +0200 |
commit | 5aab642e247331e00a73c2ad892ead41205c5a30 (patch) | |
tree | b74eb431dba5bb18bc9238107908a6e6acb210ce /src | |
parent | 8e221560c717a234a49f50a03c86a94db077c46c (diff) | |
download | sql-parser-5aab642e247331e00a73c2ad892ead41205c5a30.zip sql-parser-5aab642e247331e00a73c2ad892ead41205c5a30.tar.gz sql-parser-5aab642e247331e00a73c2ad892ead41205c5a30.tar.bz2 |
Add sanity check when detecting token type
Fixes https://github.com/phpmyadmin/phpmyadmin/issues/13483
Signed-off-by: Michal Čihař <michal@cihar.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/Context.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Context.php b/src/Context.php index 545bf08..fd8d96a 100644 --- a/src/Context.php +++ b/src/Context.php @@ -310,6 +310,9 @@ abstract class Context public static function isComment($str, $end=false) { $len = strlen($str); + if ($len == 0) { + return null; + } if ($str[0] === '#') { return Token::FLAG_COMMENT_BASH; } elseif (($len > 1) && ($str[0] === '/') && ($str[1] === '*')) { @@ -376,6 +379,9 @@ abstract class Context */ public static function isSymbol($str) { + if (strlen($str) == 0) { + return null; + } if ($str[0] === '@') { return Token::FLAG_SYMBOL_VARIABLE; } elseif ($str[0] === '`') { @@ -397,6 +403,9 @@ abstract class Context */ public static function isString($str) { + if (strlen($str) == 0) { + return null; + } if ($str[0] === '\'') { return Token::FLAG_STRING_SINGLE_QUOTES; } elseif ($str[0] === '"') { |