diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-16 14:03:34 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-01-16 14:03:34 +0300 |
commit | 480c01a9749ad1aa4ab033ae9e2270ab597c2cce (patch) | |
tree | 3562c2d5f60026f36b2accaf40dc11439b0d4227 /app/models | |
parent | 644f91552c2db87065796d3848dccc01ad939eb9 (diff) | |
parent | b1cf3225dbb6b897a8be405d599714b74cbfb547 (diff) |
Merge branch '36571-ignore-root-in-repo' into 'master'
Resolve "Error while searching for text starting with slash "/""
Closes #36571
See merge request gitlab-org/gitlab-ce!16455
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/repository.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 2ffd9558ebc..a67bb7294e6 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -938,9 +938,11 @@ class Repository end def search_files_by_name(query, ref) - return [] if empty? || query.blank? + safe_query = Regexp.escape(query.sub(/^\/*/, "")) + + return [] if empty? || safe_query.blank? - args = %W(ls-tree --full-tree -r #{ref || root_ref} --name-status | #{Regexp.escape(query)}) + args = %W(ls-tree --full-tree -r #{ref || root_ref} --name-status | #{safe_query}) run_git(args).first.lines.map(&:strip) end |