Commit 9471d58c authored by Kyle Fuller's avatar Kyle Fuller

[Search] Web search should escape queries

parent 787345f1
...@@ -58,11 +58,11 @@ module Pod ...@@ -58,11 +58,11 @@ module Pod
def web_search def web_search
query_parameter = [ query_parameter = [
('on%3Aosx' if @supported_on_osx), ('on:osx' if @supported_on_osx),
('on%3Aios' if @supported_on_ios), ('on:ios' if @supported_on_ios),
@query @query
].compact.flatten.join('%20') ].compact.flatten.join(' ')
url = "http://cocoapods.org/?q=#{query_parameter}" url = "http://cocoapods.org/?q=#{CGI.escape(query_parameter).gsub("+", "%20")}"
UI.puts("Opening #{url}") UI.puts("Opening #{url}")
open!(url) open!(url)
end end
......
...@@ -59,7 +59,12 @@ module Pod ...@@ -59,7 +59,12 @@ module Pod
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "searches with invalid regex" do it "searches with invalid regex" do
Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=NSAttributedString+CCLFormat') Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=NSAttributedString%2BCCLFormat')
run_command('search', '--web', 'NSAttributedString+CCLFormat')
end
it "should url encode search queries" do
Command::Search.any_instance.expects(:open!).with('http://cocoapods.org/?q=NSAttributedString%2BCCLFormat')
run_command('search', '--web', 'NSAttributedString+CCLFormat') run_command('search', '--web', 'NSAttributedString+CCLFormat')
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment