Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
18d0e31a
Commit
18d0e31a
authored
Aug 07, 2008
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 446645: Properly escape and understand hyphenated words in fulltext searches when using MySQL
Patch By Jesse Clark <jjclark1982@gmail.com> r=mkanat, a=mkanat
parent
70540fb1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
Mysql.pm
Bugzilla/DB/Mysql.pm
+16
-2
No files found.
Bugzilla/DB/Mysql.pm
View file @
18d0e31a
...
...
@@ -49,6 +49,7 @@ use Bugzilla::Error;
use
Bugzilla::DB::Schema::
Mysql
;
use
List::
Util
qw(max)
;
use
Text::
ParseWords
;
# This module extends the DB interface via inheritance
use
base
qw(Bugzilla::DB)
;
...
...
@@ -141,8 +142,21 @@ sub sql_fulltext_search {
my
(
$self
,
$column
,
$text
)
=
@_
;
# Add the boolean mode modifier if the search string contains
# boolean operators.
my
$mode
=
(
$text
=~
/[+-<>()~*"]/
?
"IN BOOLEAN MODE"
:
""
);
# boolean operators at the start or end of a word.
my
$mode
=
''
;
if
(
$text
=~
/(?:^|\W)[+\-<>~"()]/
||
$text
=~
/[()"*](?:$|\W)/
)
{
$mode
=
'IN BOOLEAN MODE'
;
# quote un-quoted compound words
my
@words
=
quotewords
(
'[\s()]+'
,
'delimiter'
,
$text
);
foreach
my
$word
(
@words
)
{
# match words that have word chars, non-word chars, and no quotes
if
(
$word
=~
/\w/
&&
$word
=~
m/\W/
&&
$word
!~
m/"/
)
{
$word
=
'"'
.
$word
.
'"'
;
}
}
$text
=
join
(
''
,
@words
);
}
# quote the text for use in the MATCH AGAINST expression
$text
=
$self
->
quote
(
$text
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment