fix to_tsquery disallowed chars
This commit is contained in:
parent
8320c66414
commit
2d68d7dc59
2 changed files with 7 additions and 1 deletions
|
@ -62,8 +62,8 @@ class DossierSearchService
|
|||
|
||||
def self.to_tsquery(search_terms)
|
||||
(search_terms || "")
|
||||
.strip
|
||||
.gsub(/['?\\:&|!<>\(\)]/, "") # drop disallowed characters
|
||||
.strip
|
||||
.split(/\s+/) # split words
|
||||
.map { |x| "#{x}:*" } # enable prefix matching
|
||||
.join(" & ")
|
||||
|
|
|
@ -198,5 +198,11 @@ describe DossierSearchService do
|
|||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
|
||||
describe 'search with a single forbidden character should not crash postgres' do
|
||||
let(:terms) { '? OCTO' }
|
||||
|
||||
it { expect(subject.size).to eq(3) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue