diff options
author | Andrew McCallum <andrew.mccallum@semafone.com> | 2018-01-15 14:43:12 +0000 |
---|---|---|
committer | Andrew McCallum <andrew.mccallum@semafone.com> | 2018-01-15 14:43:12 +0000 |
commit | 7ce732fb3746df82790ea80a48560e62b486b225 (patch) | |
tree | 629301d053938e106a07e9f950a76ce5477718b3 | |
parent | bce6a89152bd6d45bce67d5ecf0250ab97a0a93a (diff) | |
download | gitlab-ce-7ce732fb3746df82790ea80a48560e62b486b225.tar.gz |
Create intermediary variable for query value with leading slashes removed.
-rw-r--r-- | app/models/repository.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index a65a2b8427d..f3ec65a1885 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -940,7 +940,9 @@ class Repository def search_files_by_name(query, ref) return [] if empty? || query.blank? - args = %W(ls-tree --full-tree -r #{ref || root_ref} --name-status | #{Regexp.escape(query.sub(/^\/*/, ""))}) + safe_query = query.sub(/^\/*/, "") + + args = %W(ls-tree --full-tree -r #{ref || root_ref} --name-status | #{Regexp.escape(safe_query)}) run_git(args).first.lines.map(&:strip) end |