From d5cb87cf76d46b2fd066fd96f86677947be96fe6 Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Tue, 5 Apr 2011 15:48:03 +0200 Subject: [PATCH] Bug 5651: Question marks break searches w/ICU When a user is doing a simple keyword search, they should not be expected to deal with the magical behavior of question marks in Zebra. This fix escapes question marks, and reduces the number of false positives for identifying a "simple keyword search." Signed-off-by: Jonathan Druart Signed-off-by: Chris Cormack (cherry picked from commit ad206a73f867f6a184f64d41e4ccfa8e5bb0cd21) Signed-off-by: Chris Nighswonger --- C4/Search.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/C4/Search.pm b/C4/Search.pm index 64ebbfa3b5..56dddb0bce 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1093,10 +1093,12 @@ sub buildQuery { my $indexes_set; # If the user is sophisticated enough to specify an index, turn off field weighting, stemming, and stopword handling - if ( $operands[$i] =~ /(:|=)/ || $scan ) { + if ( $operands[$i] =~ /\w(:|=)/ || $scan ) { $weight_fields = 0; $stemming = 0; $remove_stopwords = 0; + } else { + $operands[$i] =~ s/\?/{?}/g; # need to escape question marks } my $operand = $operands[$i]; my $index = $indexes[$i]; -- 2.39.5