diff --git a/app/models/concerns/dossier_filtering_concern.rb b/app/models/concerns/dossier_filtering_concern.rb index 7883ae700..062f5fab3 100644 --- a/app/models/concerns/dossier_filtering_concern.rb +++ b/app/models/concerns/dossier_filtering_concern.rb @@ -29,7 +29,7 @@ module DossierFilteringConcern } scope :filter_ilike, lambda { |table, column, search_terms| - safe_quoted_terms = search_terms.map { "%#{sanitize_sql_like(_1)}%" } + safe_quoted_terms = search_terms.map(&:strip).map { "%#{sanitize_sql_like(_1)}%" } table_column = DossierFilterService.sanitized_column(table, column) where("#{table_column} LIKE ANY (ARRAY[?])", safe_quoted_terms) diff --git a/spec/services/dossier_filter_service_spec.rb b/spec/services/dossier_filter_service_spec.rb index 5aac6d289..5a6983c0e 100644 --- a/spec/services/dossier_filter_service_spec.rb +++ b/spec/services/dossier_filter_service_spec.rb @@ -443,7 +443,7 @@ describe DossierFilterService do end context 'for type_de_champ table' do - let(:filter) { [type_de_champ.libelle, 'keep'] } + let(:filter) { [type_de_champ.libelle, ' keep '] } let(:kept_dossier) { create(:dossier, procedure:) } let(:discarded_dossier) { create(:dossier, procedure:) }