Provides a fix for URI parsing exceptions InvalidURIError #1

Merged
merged 1 commit into from May 3, 2012
Jump to file or symbol
Failed to load files and symbols.
+5 −5
Split
@@ -42,14 +42,14 @@ def self.by(result)
abstract = result['Abstract'] unless result['Abstract'].empty?
abstract_text = result['AbstractText'] unless result['AbstractText'].empty?
abstract_source = result['AbstractSource'] unless result['AbstractSource'].empty?
- abstract_url = URI.parse(result['AbstractURL']) unless result['AbstractURL'].empty?
- image = URI.parse(result['Image']) unless result['Image'].empty?
+ abstract_url = URI.parse(URI.escape(result['AbstractURL'])) unless result['AbstractURL'].empty?
+ image = URI.parse(URI.escape(result['Image'])) unless result['Image'].empty?
heading = result['Heading'] unless result['Heading'].empty?
answer = result['Answer'] unless result['Answer'].empty?
answer_type = result['AnswerType'] unless result['AnswerType'].empty?
definition = result['Definition'] unless result['Definition'].empty?
definition_source = result['DefinitionSource'] unless result['DefinitionSource'].empty?
- definition_url = URI.parse(result['DefinitionURL']) unless result['DefinitionURL'].empty?
+ definition_url = URI.parse(URI.escape(result['DefinitionURL'])) unless result['DefinitionURL'].empty?
type = result['Type'] unless result['Type'].empty?
if result['Results']
@@ -79,4 +79,4 @@ def self.by(result)
end
end
-end
+end
@@ -799,7 +799,7 @@ def test_zci_exclusive
"AbstractURL"=>"http://en.wikipedia.org/wiki/Lorem_Ipsum",
"Image"=>"",
"DefinitionURL"=>
- "http://www.thefreedictionary.com/_/search.aspx?pid=aff18&word=lorem%2520ipsum",
+ "http://www.merriam-webster.com/dictionary/lorem ipsum",
"DefinitionSource"=>"TheFreeDictionary",
"AbstractText"=>"",
"Type"=>"E"}