diff options
author | Andrew McCallum <andrew.mccallum@semafone.com> | 2018-01-16 12:40:51 +0300 |
---|---|---|
committer | Andrew McCallum <andrew.mccallum@semafone.com> | 2018-01-16 12:40:51 +0300 |
commit | b1cf3225dbb6b897a8be405d599714b74cbfb547 (patch) | |
tree | 97c02388bb402395eeaade84279a6bda6f3dafb4 | |
parent | a539e03d7e4f12cfaa3ae7998dd111f498f4c8dc (diff) |
Move Regexp.escape(), fix formatting on tests.
-rw-r--r-- | app/models/repository.rb | 4 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index c258cffb274..a67bb7294e6 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -938,11 +938,11 @@ class Repository end def search_files_by_name(query, ref) - safe_query = query.sub(/^\/*/, "") + 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(safe_query)}) + args = %W(ls-tree --full-tree -r #{ref || root_ref} --name-status | #{safe_query}) run_git(args).first.lines.map(&:strip) end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 6767d818009..d9395ca61d7 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -675,9 +675,9 @@ describe Repository do end it 'properly handles when query is only slashes' do - results = repository.search_files_by_name('//', 'master') + results = repository.search_files_by_name('//', 'master') - expect(results).to match_array([]) + expect(results).to match_array([]) end it 'properly handles when query is not present' do |