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

Parser fails when string contains ' followed by -- #354

Open
carlomanf opened this issue Apr 24, 2022 · 0 comments
Open

Parser fails when string contains ' followed by -- #354

carlomanf opened this issue Apr 24, 2022 · 0 comments

Comments

@carlomanf
Copy link

carlomanf commented Apr 24, 2022

The v4.4.0 parser gives incorrect results when a string contains an escaped ' character followed by the -- character sequence later in the string.

With the last two below examples, the where clause does not get parsed.

$parser = new PHPSQLParser();
$parser->parse('update table1 set col1 = \'\\\'\' where col2 = 1');      // works
$parser->parse('update table1 set col1 = \'--\' where col2 = 1');        // works
$parser->parse('update table1 set col1 = \'--\\\'\' where col2 = 1');    // works
$parser->parse('update table1 set col1 = \'\\\'--\' where col2 = 1');    // does not work
$parser->parse('update table1 set col1 = \'a\\\'b--c\' where col2 = 1'); // does not work

What happens to the where clause:

array(3) {
	["expr_type"]=>
	string(5) "const"
	["base_expr"]=>
	string(21) "'\'--' where col2 = 1"
	["sub_tree"]=>
	bool(false)
}
array(3) {
	["expr_type"]=>
	string(5) "const"
	["base_expr"]=>
	string(24) "'a\'b--c' where col2 = 1"
	["sub_tree"]=>
	bool(false)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant