Merge branch 'escape-file-extension' into 'master'

Escape file extension when parsing search results

When a file extension contains characters which have a meaning in regular expressions, the search may crash.

Fixes #18553 

See merge request !5141
This commit is contained in:
Robert Speicher 2016-07-07 17:47:03 +00:00
commit 86d83a3a85
2 changed files with 2 additions and 1 deletions

View File

@ -8,6 +8,7 @@ v 8.10.0 (unreleased)
- Wrap code blocks on Activies and Todos page. !4783 (winniehell)
- Align flash messages with left side of page content !4959 (winniehell)
- Display last commit of deleted branch in push events !4699 (winniehell)
- Escape file extension when parsing search results !5141 (winniehell)
- Apply the trusted_proxies config to the rack request object for use with rack_attack
- Add Sidekiq queue duration to transaction metrics.
- Add a new column `artifacts_size` to table `ci_builds` !4964

View File

@ -911,7 +911,7 @@ class Repository
if line =~ /^.*:.*:\d+:/
ref, filename, startline = line.split(':')
startline = startline.to_i - index
extname = File.extname(filename)
extname = Regexp.escape(File.extname(filename))
basename = filename.sub(/#{extname}$/, '')
break
end