[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum length of a delimiter is 15 characters. #150

Merged
merged 1 commit into from
May 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Maximum length of a delimiter is 15 characters.
Fixes #12.

Signed-off-by: Dan Ungureanu <udan1107@gmail.com>
  • Loading branch information
Dan Ungureanu committed May 7, 2017
commit 60bd0a2c68e8e0d90fcec05cabbc475f35d02889
4 changes: 3 additions & 1 deletion src/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,10 @@ public function lex()

// Parsing the delimiter.
$this->delimiter = null;
while (++$this->last < $this->len && !Context::isWhitespace($this->str[$this->last])) {
$delimiterLen = 0;
while (++$this->last < $this->len && !Context::isWhitespace($this->str[$this->last]) && $delimiterLen < 15) {
$this->delimiter .= $this->str[$this->last];
++$delimiterLen;
}

if (empty($this->delimiter)) {
Expand Down
1 change: 1 addition & 0 deletions tests/Lexer/LexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function testLexProvider()
array('lexer/lexDelimiterErr1'),
array('lexer/lexDelimiterErr2'),
array('lexer/lexDelimiterErr3'),
array('lexer/lexDelimiterLen'),
array('lexer/lexKeyword'),
array('lexer/lexKeyword2'),
array('lexer/lexNumber'),
Expand Down
2 changes: 2 additions & 0 deletions tests/data/lexer/lexDelimiterLen.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DELIMITER abcdefghijklmnopqrstuvwxyz
SELECT 1 abcdefghijklmnopqrstuvwxyz
7 changes: 7 additions & 0 deletions tests/data/lexer/lexDelimiterLen.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
a:4:{s:5:"query";s:73:"DELIMITER abcdefghijklmnopqrstuvwxyz
SELECT 1 abcdefghijklmnopqrstuvwxyz
";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:73:"DELIMITER abcdefghijklmnopqrstuvwxyz
SELECT 1 abcdefghijklmnopqrstuvwxyz
";s:3:"len";i:73;s:4:"last";i:73;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:13:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:9:"DELIMITER";s:5:"value";s:9:"DELIMITER";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:9;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:15:"abcdefghijklmno";s:5:"value";s:15:"abcdefghijklmno";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:10;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:11:"pqrstuvwxyz";s:5:"value";s:11:"pqrstuvwxyz";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:25;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"
";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:36;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:37;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:43;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:44;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:45;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:15:"abcdefghijklmno";s:5:"value";s:15:"abcdefghijklmno";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:46;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:11:"pqrstuvwxyz";s:5:"value";s:11:"pqrstuvwxyz";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:61;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"
";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:72;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:13;s:3:"idx";i:0;}s:9:"delimiter";s:15:"abcdefghijklmno";s:12:"delimiterLen";i:15;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";N;s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:0:{}}}