summaryrefslogtreecommitdiff
path: root/app/helpers/search_helper.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /app/helpers/search_helper.rb
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
downloadgitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'app/helpers/search_helper.rb')
-rw-r--r--app/helpers/search_helper.rb30
1 files changed, 14 insertions, 16 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index a7acc0cd7db..86012352c8b 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -360,33 +360,31 @@ module SearchHelper
end
end
+ def search_md_sanitize(source)
+ search_sanitize(markdown(search_truncate(source)))
+ end
+
+ def simple_search_highlight_and_truncate(text, phrase, options = {})
+ highlight(search_sanitize(search_truncate(text)), phrase.split, options)
+ end
+
# Sanitize a HTML field for search display. Most tags are stripped out and the
# maximum length is set to 200 characters.
- def search_md_sanitize(source)
- source = Truncato.truncate(
+ def search_truncate(source)
+ Truncato.truncate(
source,
count_tags: false,
count_tail: false,
+ filtered_tags: %w(img),
max_length: 200
)
+ end
- html = markdown(source)
-
+ def search_sanitize(html)
# Truncato's filtered_tags and filtered_attributes are not quite the same
sanitize(html, tags: %w(a p ol ul li pre code))
end
- def simple_search_highlight_and_truncate(text, phrase, options = {})
- text = Truncato.truncate(
- text,
- count_tags: false,
- count_tail: false,
- max_length: options.delete(:length) { 200 }
- )
-
- highlight(text, phrase.split, options)
- end
-
# _search_highlight is used in EE override
def highlight_and_truncate_issuable(issuable, search_term, _search_highlight)
return unless issuable.description.present?
@@ -406,7 +404,7 @@ module SearchHelper
# Closed is considered "danger" for MR so we need to handle separately
if issuable.is_a?(::MergeRequest)
if issuable.merged?
- :primary
+ :info
elsif issuable.closed?
:danger
else