[open-ils-commits] [GIT] Evergreen ILS branch master updated. b15a61ffc934e5e4f558de69505f904b4de0d2e3
Evergreen Git
git at git.evergreen-ils.org
Fri Oct 23 23:55:10 EDT 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via b15a61ffc934e5e4f558de69505f904b4de0d2e3 (commit)
via b517367f16163026aa12459e9c3913003f94eab4 (commit)
from 01b02553359a0c8b2cbd2d8fabc06c6d626b2f08 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b15a61ffc934e5e4f558de69505f904b4de0d2e3
Author: Galen Charlton <gmc at esilibrary.com>
Date: Fri Oct 23 20:03:07 2015 +0000
LP#1509479: set a limit on loops in QP's decompose() method
Following a suggestion of Dan Scott's, add a pair of
suspenders to the belt and enforce an arbitrary limit
of 1000 passes through QP->decompse().
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Dan Scott <dscott at laurentian.ca>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
index ba90f18..7f1f235 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
@@ -951,8 +951,14 @@ sub decompose {
my $remainder = '';
+ my $loops = 0;
while (!$remainder) {
- warn ' 'x$recursing."Start of the loop. last_type: $last_type, joiner: ".$struct->joiner.", struct: $struct\n" if $self->debug;
+ $loops++;
+ warn ' 'x$recursing."Start of the loop. loop: $loops last_type: $last_type, joiner: ".$struct->joiner.", struct: $struct\n" if $self->debug;
+ if ($loops > 1000) { # the most magical of numbers...
+ warn ' 'x$recursing." got to $loops loops; aborting\n" if $self->debug;
+ last;
+ }
if ($last_type eq 'FEND' and $fstart and $fstart != $struct) { # fall back further
$remainder = $_;
last;
commit b517367f16163026aa12459e9c3913003f94eab4
Author: Galen Charlton <gmc at esilibrary.com>
Date: Fri Oct 23 19:23:05 2015 +0000
LP#1509479: fix infinite loop bug in QueryParser
An unclosed phrase search that has a modifier can cause QueryParser to
enter an infinite loop, tying up open-ils.storage backends.
Examples of such searches include:
-"cats and dogs
subject:+"physical chemistry
This patch fixes the bug by allowing the end of the query string
to terminate a phrase (in addition to a quotation mark).
To test:
[1] Verify that the t/21-QueryParser.t unit test passes
[2] To test in a *development* database, before applying the patch
run one of the example queries. Observe that no
results are returned, and that one of the open-ils.storage
drones is running at 100% CPU.
[3] Apply the patch and restart the open-ils.storage service.
[4] Try the query again; this time, it should return results
immediately without causing an open-ils.storage drone to
peg a CPU.
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Dan Scott <dscott at laurentian.ca>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
index 1b5458d..ba90f18 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
@@ -1159,7 +1159,7 @@ sub decompose {
$_ = $';
$last_type = 'CLASS';
- } elsif (/^\s*($$r{required_re}|$$r{disallowed_re}|$$r{negated_re})?"([^"]+)"/) { # phrase, always anded
+ } elsif (/^\s*($$r{required_re}|$$r{disallowed_re}|$$r{negated_re})?"([^"]+)(?:"|$)/) { # phrase, always anded
warn ' 'x$recursing.'Encountered' . ($1 ? " ['$1' modified]" : '') . " phrase: $2\n" if $self->debug;
my $req_ness = $1 || '';
diff --git a/Open-ILS/src/perlmods/t/21-QueryParser.t b/Open-ILS/src/perlmods/t/21-QueryParser.t
index 55ffd6f..81bf051 100644
--- a/Open-ILS/src/perlmods/t/21-QueryParser.t
+++ b/Open-ILS/src/perlmods/t/21-QueryParser.t
@@ -60,6 +60,18 @@ is($QParser->superpage(), 1, 'Superpage stays set');
is($QParser->superpage_size(1000), 1000, 'Superpage size setting works');
is($QParser->superpage_size(), 1000, 'Superpage size stays set');
+init_qp();
+eval {
+ local $SIG{ALRM} = sub { die "timed out!\n" };
+ alarm 1;
+ $QParser->parse('-"unclosed phrase');
+};
+if ($@) {
+ fail('parsing modified unclosed phrase query timed out');
+} else {
+ pass('successfully parsed modified unclosed phrase query');
+}
+
# It's unfortunate not to be able to use the following tests immediately, but
# they reflect assumptions that need to be updated in light of new qp_fix code.
# Also,, canonicalization may not preserve insignificant whitespace nor the
-----------------------------------------------------------------------
Summary of changes:
.../lib/OpenILS/Application/Storage/QueryParser.pm | 10 ++++++++--
Open-ILS/src/perlmods/t/21-QueryParser.t | 12 ++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list