Escape apostrophizes char on filter
This commit is contained in:
parent
a781473b42
commit
fd9eaa5a4d
2 changed files with 11 additions and 1 deletions
|
@ -129,7 +129,7 @@ class DossiersListGestionnaireService
|
|||
def where_filter
|
||||
filter_preference_list.inject('') do |acc, preference|
|
||||
unless preference.filter.blank?
|
||||
filter = preference.filter.gsub('*', '%')
|
||||
filter = preference.filter.gsub('*', '%').gsub("'", "''")
|
||||
filter = "%"+filter+"%" unless filter.include? '%'
|
||||
|
||||
value = preference.table_with_s_attr
|
||||
|
|
|
@ -171,6 +171,16 @@ describe DossiersListGestionnaireService do
|
|||
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE 'plop%plip'" }
|
||||
end
|
||||
|
||||
context "when filter containe the character <'> " do
|
||||
before do
|
||||
gestionnaire.preference_list_dossiers
|
||||
.find_by(table: 'entreprise', attr: 'raison_sociale', procedure: nil)
|
||||
.update_column :filter, "MCDONALD'S FRANCE"
|
||||
end
|
||||
|
||||
it { is_expected.to eq "CAST(dossiers.id as TEXT) LIKE '%23%' AND CAST(entreprises.raison_sociale as TEXT) LIKE '%MCDONALD''S FRANCE%'" }
|
||||
end
|
||||
|
||||
context 'when preference list contain a champ' do
|
||||
before do
|
||||
create :preference_list_dossier,
|
||||
|
|
Loading…
Reference in a new issue