Subject: | parse does not fail on query with mismatched close paren |
Using Search::QueryParser 0.94 and Perl 5.8.8.
The "parse" method does not fail when given a query that has an
unmatched closing parenthesis. The closing parenthesis and anything
after it are silently ignored. E.g. this query:
foo bar) this is ignored
will unparse into:
:foo :bar
The attached patch will sets the error string and returns undef if this
error condition occurs.
Subject: | QueryParser.pm.0.94-patch.txt |
*** QueryParser.pm.0.94 2009-12-15 17:38:36.000000000 -0700
--- QueryParser.pm 2009-12-15 17:47:10.000000000 -0700
***************
*** 343,349 ****
! sub parse { return (_parse(@_))[0]; } # just return 1st result from _parse
sub _parse{ # returns ($parsedQuery, $restOfString)
my $self = shift;
--- 343,360 ----
! sub parse {
! my $s_orig = $_[1];
! my ($parsedQuery, $restOfString) = _parse(@_);
! if ($restOfString) {
! $self->{err} = "[$s_orig] : unable to parse entire query:"
! . " [$restOfString]";
! return undef;
! }
! else {
! return $parsedQuery;
! }
! }
sub _parse{ # returns ($parsedQuery, $restOfString)
my $self = shift;