OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix untransliterable characters breaking the value binding
Oliver Günther04e5465286a3
diff --git a/app/models/queries/work_packages/filter/attachment_base_filter.rb b/app/models/queries/work_packages/filter/attachment_base_filter.rbindex 322d0f0b3ab..be86677b1b1 100644--- a/app/models/queries/work_packages/filter/attachment_base_filter.rb+++ b/app/models/queries/work_packages/filter/attachment_base_filter.rb@@ -44,7 +44,7 @@ class Queries::WorkPackages::Filter::AttachmentBaseFilter < Queries::WorkPackageSELECT 1 FROM #{attachment_table}WHERE #{attachment_table}.container_id = #{WorkPackage.table_name}.idAND #{attachment_table}.container_type = '#{WorkPackage.name}'- AND #{tsv_condition}+ #{tsv_condition}SQLend@@ -53,10 +53,16 @@ class Queries::WorkPackages::Filter::AttachmentBaseFilter < Queries::WorkPackageenddef tsv_condition- OpenProject::FullTextSearch.tsv_where(attachment_table,- search_column,- values.first,- normalization: normalization_type)+ condition = OpenProject::FullTextSearch.tsv_where(attachment_table,+ search_column,+ values.first,+ normalization: normalization_type)++ if condition+ "AND #{condition}"+ else+ ''+ endenddef search_columndiff --git a/lib/open_project/full_text_search.rb b/lib/open_project/full_text_search.rbindex 8c6c0fa7085..b666b8e4c45 100644--- a/lib/open_project/full_text_search.rb+++ b/lib/open_project/full_text_search.rb@@ -35,6 +35,8 @@ module OpenProjectif OpenProject::Database.allows_tsv?column = "\"#{table_name}\".\"#{column_name}_tsv\""query = tokenize(value, concatenation, normalization)+ return if query.blank?+language = OpenProject::Configuration.main_content_languageActiveRecord::Base.send(@@ -68,12 +70,12 @@ module OpenProjectenddef self.normalize_text(text)- I18n.with_locale(:en) { I18n.transliterate(text.to_s.downcase) }+ I18n.with_locale(:en) { I18n.transliterate(text.to_s.downcase, replacement: '') }enddef self.normalize_filename(filename)name_in_words = to_words filename.to_s.downcase- I18n.with_locale(:en) { I18n.transliterate(name_in_words) }+ I18n.with_locale(:en) { I18n.transliterate(name_in_words, replacement: '') }enddef self.to_words(text)diff --git a/lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb b/lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rbindex 9f0d1ce6438..51c14688a01 100644--- a/lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb+++ b/lib_static/plugins/acts_as_searchable/lib/acts_as_searchable.rb@@ -90,7 +90,7 @@ module Redminetoken_clauses = searchable_column_conditionsif OpenProject::Database.allows_tsv?- tsv_clauses = searchable_tsv_column_conditions(tokens)+ tsv_clauses = searchable_tsv_column_conditions(tokens).compactendif searchable_options[:search_custom_fields]diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rbindex b8998cb20e7..787c9dae59a 100644--- a/spec/controllers/search_controller_spec.rb+++ b/spec/controllers/search_controller_spec.rb@@ -138,6 +138,22 @@ RSpec.describe SearchController doendend+ context 'when searching in all projects with an untransliterable character' do+ before do+ work_package_1.update_column(:subject, 'Something 会议 something')+ get :index, params: { q: '会议', scope: 'all' }+ end++ it_behaves_like 'successful search'++ it 'returns the result', :aggregate_failures do+ expect(assigns(:results).count).to be(1)+ expect(assigns(:results)).to include(work_package_1)+ expect(assigns(:results_count)).to be_a(Hash)+ expect(assigns(:results_count)['work_packages']).to be(1)+ end+ end+context 'when searching in project and its subprojects' dobefore { get :index, params: { q: 'issue', project_id: project.id, scope: 'subprojects' } }