Escape search term before passing it to Regexp.new (!6241)

This commit is contained in:
winniehell 2016-09-07 15:16:22 +02:00
parent 0e3f7927d5
commit e64e45db54
2 changed files with 4 additions and 1 deletions

View file

@ -10,6 +10,7 @@ v 8.12.0 (unreleased)
- Change logo animation to CSS (ClemMakesApps)
- Instructions for enabling Git packfile bitmaps !6104
- Fix pagination on user snippets page
- Escape search term before passing it to Regexp.new !6241 (winniehell)
- Change merge_error column from string to text type
- Reduce contributions calendar data payload (ClemMakesApps)
- Add `web_url` field to issue, merge request, and snippet API objects (Ben Boeckel)

View file

@ -7,8 +7,10 @@ module SearchHelper
projects_autocomplete(term)
].flatten
search_pattern = Regexp.new(Regexp.escape(term), "i")
generic_results = project_autocomplete + default_autocomplete + help_autocomplete
generic_results.select! { |result| result[:label] =~ Regexp.new(term, "i") }
generic_results.select! { |result| result[:label] =~ search_pattern }
[
resources_results,