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

[Search] Web search should escape queries

parent 787345f1
......@@ -58,11 +58,11 @@ module Pod
def web_search
query_parameter = [
('on%3Aosx' if @supported_on_osx),
('on%3Aios' if @supported_on_ios),
('on:osx' if @supported_on_osx),
('on:ios' if @supported_on_ios),
@query
].compact.flatten.join('%20')
url = "http://cocoapods.org/?q=#{query_parameter}"
].compact.flatten.join(' ')
url = "http://cocoapods.org/?q=#{CGI.escape(query_parameter).gsub("+", "%20")}"
UI.puts("Opening #{url}")
open!(url)
end
......
......@@ -59,7 +59,12 @@ module Pod
extend SpecHelper::TemporaryRepos
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')
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