Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-12-07 10:58:52 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-07 10:58:52 +0300
commit5bf5e1293ad952357635460431cbc4b27340034d (patch)
tree2e7750ea52207de92ae712be694a30db98be3151
parentbe44a258256ec9ba12876f56449078fcbb1431e0 (diff)
Add latest changes from gitlab-org/gitlab@16-6-stable-ee
-rw-r--r--app/models/concerns/pg_full_text_searchable.rb2
-rw-r--r--spec/models/concerns/pg_full_text_searchable_spec.rb10
2 files changed, 12 insertions, 0 deletions
diff --git a/app/models/concerns/pg_full_text_searchable.rb b/app/models/concerns/pg_full_text_searchable.rb
index b7ca6f61573..b31a52f98ca 100644
--- a/app/models/concerns/pg_full_text_searchable.rb
+++ b/app/models/concerns/pg_full_text_searchable.rb
@@ -26,6 +26,7 @@ module PgFullTextSearchable
TEXT_SEARCH_DICTIONARY = 'english'
URL_SCHEME_REGEX = %r{(?<=\A|\W)\w+://(?=\w+)}
TSQUERY_DISALLOWED_CHARACTERS_REGEX = %r{[^a-zA-Z0-9 .@/\-_"]}
+ XML_TAG_REGEX = %r{</?([^>]+)>}
def update_search_data!
tsvector_sql_nodes = self.class.pg_full_text_searchable_columns.map do |column, weight|
@@ -55,6 +56,7 @@ module PgFullTextSearchable
column_text = self[column].gsub(LONG_WORDS_REGEX, ' ')
column_text = column_text[0..(TSVECTOR_MAX_LENGTH - 1)]
column_text = ActiveSupport::Inflector.transliterate(column_text)
+ column_text = column_text.gsub(XML_TAG_REGEX, ' \1 ')
Arel::Nodes::NamedFunction.new(
'setweight',
diff --git a/spec/models/concerns/pg_full_text_searchable_spec.rb b/spec/models/concerns/pg_full_text_searchable_spec.rb
index 8e3b65cf125..7da48489e12 100644
--- a/spec/models/concerns/pg_full_text_searchable_spec.rb
+++ b/spec/models/concerns/pg_full_text_searchable_spec.rb
@@ -146,6 +146,16 @@ RSpec.describe PgFullTextSearchable, feature_category: :global_search do
expect(model_class.pg_full_text_search('123')).to contain_exactly(with_dash)
end
end
+
+ context 'when text has XML tags' do
+ let(:with_xml) { model_class.create!(project: project, namespace: project.project_namespace, title: '<rain>go away</rain>', description: 'description') }
+
+ it 'removes XML tag syntax' do
+ with_xml.update_search_data!
+
+ expect(model_class.pg_full_text_search('rain')).to contain_exactly(with_xml)
+ end
+ end
end
describe '#update_search_data!' do