summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-23 03:48:49 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-23 03:48:49 +0200
commit4518c70b3f058c88b5ff74798d44c95e3e8bd112 (patch)
tree5af51c36e4ede98238c586f516cd51bb5999d495
parentb1fa012bc8f89aa7a4a86cc2b7d97d68136358f7 (diff)
downloadbugzilla-4518c70b3f058c88b5ff74798d44c95e3e8bd112.tar.gz
bugzilla-4518c70b3f058c88b5ff74798d44c95e3e8bd112.tar.xz
Bug 578494: When doing a QuickSearch on a phrase, pass the phrase quoted
to the fulltext engine, so that it knows it's a phrase. r=LpSolit, a=mkanat
-rw-r--r--Bugzilla/DB.pm6
-rw-r--r--Bugzilla/Search/Quicksearch.pm11
2 files changed, 13 insertions, 4 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 117c3a7b0..43fcd6e9a 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -45,6 +45,7 @@ use Bugzilla::DB::Schema;
use List::Util qw(max);
use Storable qw(dclone);
+use Text::ParseWords qw(shellwords);
#####################################################################
# Constants
@@ -383,8 +384,9 @@ sub sql_fulltext_search {
# make the string lowercase to do case insensitive search
my $lower_text = lc($text);
- # split the text we search for into separate words
- my @words = split(/\s+/, $lower_text);
+ # split the text we're searching for into separate words, understanding
+ # quotes.
+ my @words = shellwords($lower_text);
# surround the words with wildcards and SQL quotes so we can use them
# in LIKE search clauses
diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm
index df4383ef9..17a371c35 100644
--- a/Bugzilla/Search/Quicksearch.pm
+++ b/Bugzilla/Search/Quicksearch.pm
@@ -310,7 +310,7 @@ sub _handle_special_first_chars {
if ($firstChar eq '#') {
addChart('short_desc', 'substring', $baseWord, $negate);
- addChart('content', 'matches', $baseWord, $negate);
+ addChart('content', 'matches', _matches_phrase($baseWord), $negate);
return 1;
}
if ($firstChar eq ':') {
@@ -470,7 +470,7 @@ sub _default_quicksearch_word {
addChart('alias', 'substring', $word, $negate);
addChart('short_desc', 'substring', $word, $negate);
addChart('status_whiteboard', 'substring', $word, $negate);
- addChart('content', 'matches', $word, $negate);
+ addChart('content', 'matches', _matches_phrase($word), $negate);
}
sub _handle_urls {
@@ -522,6 +522,13 @@ sub splitString {
return @parts;
}
+# Quote and escape a phrase appropriately for a "content matches" search.
+sub _matches_phrase {
+ my ($phrase) = @_;
+ $phrase =~ s/"/\\"/g;
+ return "\"$phrase\"";
+}
+
# Expand found prefixes to states or resolutions
sub matchPrefixes {
my $hr_states = shift;