From: Mike Rylander Date: Fri, 24 Feb 2012 18:40:06 +0000 (-0500) Subject: Correctly quote regexp-y characters in phrase quoting helper X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=44bd6367fa8bc8e0283954ace17c7f1555035eb2;p=working%2FEvergreen.git Correctly quote regexp-y characters in phrase quoting helper There was one extra character that caused the use of quotemeta() to not actually happen. This broke two things: 1) phrase searching when the phrase had certain special characters in it -- test case: "c++" 2) use of relevance bumps in the same situation Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index c1fb759811..05159d99fe 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -25,7 +25,7 @@ sub quote_phrase_value { my $right_anchored = $value =~ m/\$$/; $value =~ s/\^// if $left_anchored; $value =~ s/\$$// if $right_anchored; - $value =~ quotemeta($value); + $value = quotemeta($value); $value = '^' . $value if $left_anchored; $value = "$value\$" if $right_anchored; return $self->quote_value($value); @@ -573,13 +573,13 @@ sub rel_bump { return '' if (!@$only_atoms); if ($bump eq 'first_word') { - return " /* first_word */ COALESCE(NULLIF( (naco_normalize(".$node->table_alias.".value) ~ ('^'||naco_normalize(".$self->QueryParser->quote_value($only_atoms->[0]->content)."))), FALSE )::INT * $multiplier, 1)"; + return " /* first_word */ COALESCE(NULLIF( (naco_normalize(".$node->table_alias.".value) ~ ('^'||naco_normalize(".$self->QueryParser->quote_phrase_value($only_atoms->[0]->content)."))), FALSE )::INT * $multiplier, 1)"; } elsif ($bump eq 'full_match') { return " /* full_match */ COALESCE(NULLIF( (naco_normalize(".$node->table_alias.".value) ~ ('^'||". - join( "||' '||", map { "naco_normalize(".$self->QueryParser->quote_value($_->content).")" } @$only_atoms )."||'\$')), FALSE )::INT * $multiplier, 1)"; + join( "||' '||", map { "naco_normalize(".$self->QueryParser->quote_phrase_value($_->content).")" } @$only_atoms )."||'\$')), FALSE )::INT * $multiplier, 1)"; } elsif ($bump eq 'word_order') { return " /* word_order */ COALESCE(NULLIF( (naco_normalize(".$node->table_alias.".value) ~ (". - join( "||'.*'||", map { "naco_normalize(".$self->QueryParser->quote_value($_->content).")" } @$only_atoms ).")), FALSE )::INT * $multiplier, 1)"; + join( "||'.*'||", map { "naco_normalize(".$self->QueryParser->quote_phrase_value($_->content).")" } @$only_atoms ).")), FALSE )::INT * $multiplier, 1)"; } return '';