Subject: | Parser strips comments from within quoted strings |
Date: | Wed, 3 Mar 2010 12:32:15 -0600 |
To: | bug-SQL-Statement <bug-SQL-Statement [...] rt.cpan.org> |
From: | Rob Kennedy <kennedyri [...] gmail.com> |
When an SQL statement contains two consecutive dashes,
SQL::Parser::parse strips the remainder of the line, even when those
dashes are part of another token.
use SQL::Statement;
$parser = SQL::Parser->new();
$stmt = SQL::Statement->new("select a from b where good = 'good' ", $parser);
$stmt = SQL::Statement->new("select a from b where passes = '--'\n'
", $parser);
$stmt = SQL::Statement->new("select a from b where bad = '--' ", $parser);
The "good" case is fine. The "passes" case should fail due to the
extra apostrophe at the end of the input, after the newline, but the
parser accepts it. The "bad" case should pass because the dashes are
inside a quoted string. The error I get:
Mismatched single quote before: 'select a from b where bad = ''
I'm using SQL::Statement 1.23 with Perl 5.10.0 on Solaris 10.
It's clear from Parser.pm line 85 what the problem is. The regular
expression to strip the first comment gets applied before any
tokenization.
--
Rob Kennedy