summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirceu Pereira Tiegs <dirceutiegs@gmail.com>2015-10-14 20:14:24 -0300
committerDirceu Pereira Tiegs <dirceutiegs@gmail.com>2015-10-21 10:20:40 -0200
commitd7bcfe4fc020529f9b6ed2a75dfb2f31acded080 (patch)
tree00f1822da2a9c7083661603d11fdfbee383e966b
parent976400c1e6c653ce93cd29d32a007c091a38f970 (diff)
downloadgitlab-ce-dirceu/gitlab-ce-fix-project-search-with-unmatched-parentheses.tar.gz
Fix issue #3055 (project search with unmatched parentheses)dirceu/gitlab-ce-fix-project-search-with-unmatched-parentheses
-rw-r--r--app/models/repository.rb2
-rw-r--r--lib/gitlab/project_search_results.rb2
-rw-r--r--spec/lib/gitlab/project_search_results_spec.rb4
3 files changed, 4 insertions, 4 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 8b51602bc23..04e1114608b 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -482,7 +482,7 @@ class Repository
def search_files(query, ref)
offset = 2
- args = %W(git grep -i -n --before-context #{offset} --after-context #{offset} #{query} #{ref || root_ref})
+ args = %W(git grep -i -n --before-context #{offset} --after-context #{offset} -e #{query} #{ref || root_ref})
Gitlab::Popen.popen(args, path_to_repo).first.scrub.split(/^--$/)
end
diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb
index 0dab7bcfa4d..0a2be605af9 100644
--- a/lib/gitlab/project_search_results.rb
+++ b/lib/gitlab/project_search_results.rb
@@ -9,7 +9,7 @@ module Gitlab
else
nil
end
- @query = Shellwords.shellescape(query) if query.present?
+ @query = query
end
def objects(scope, page = nil)
diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb
index 32a25f08cac..19327ac8ce0 100644
--- a/spec/lib/gitlab/project_search_results_spec.rb
+++ b/spec/lib/gitlab/project_search_results_spec.rb
@@ -9,7 +9,7 @@ describe Gitlab::ProjectSearchResults do
it { expect(results.project).to eq(project) }
it { expect(results.repository_ref).to be_nil }
- it { expect(results.query).to eq('hello\\ world') }
+ it { expect(results.query).to eq('hello world') }
end
describe 'initialize with ref' do
@@ -18,6 +18,6 @@ describe Gitlab::ProjectSearchResults do
it { expect(results.project).to eq(project) }
it { expect(results.repository_ref).to eq(ref) }
- it { expect(results.query).to eq('hello\\ world') }
+ it { expect(results.query).to eq('hello world') }
end
end