search: exclude more special characters
This commit is contained in:
parent
b07bdebc69
commit
437f73b4ce
2 changed files with 7 additions and 1 deletions
|
@ -39,7 +39,7 @@ class DossierSearchService
|
||||||
|
|
||||||
def self.to_tsquery(search_terms)
|
def self.to_tsquery(search_terms)
|
||||||
search_terms.strip
|
search_terms.strip
|
||||||
.gsub(/['?\\:&|!]/, "") # drop disallowed characters
|
.gsub(/['?\\:&|!<>\(\)]/, "") # drop disallowed characters
|
||||||
.split(/\s+/) # split words
|
.split(/\s+/) # split words
|
||||||
.map { |x| "#{x}:*" } # enable prefix matching
|
.map { |x| "#{x}:*" } # enable prefix matching
|
||||||
.join(" & ")
|
.join(" & ")
|
||||||
|
|
|
@ -90,5 +90,11 @@ describe DossierSearchService do
|
||||||
|
|
||||||
it { expect(subject.size).to eq(1) }
|
it { expect(subject.size).to eq(1) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'search with characters disallowed by the tsquery parser' do
|
||||||
|
let(:terms) { "'?\\:&!(OCTO) <plop>" }
|
||||||
|
|
||||||
|
it { expect(subject.size).to eq(1) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue