Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Fixes: UTF-8 regexp with ASCII-8BIT string error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Lovelett committed Jul 30, 2011
1 parent f18bd1a commit a6958ae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/imasquerade/extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,20 @@ def Extractor.fetch_and_parse_feed_from_apple(url)
reader = Nokogiri::XML(response)
feed_url = reader.xpath('//@feed-url')
return feed_url[0].value unless feed_url.count == 0
list = Plist::parse_xml(response)
response.force_encoding("UTF-8") if response.encoding == Encoding::ASCII_8BIT
begin
list = Plist::parse_xml(response)
rescue RuntimeError => bang
list = {}
end
if list.has_key?('action') && list['action']['kind'] == "Goto" then
response = Extractor.fetch_and_parse_feed_from_apple(list['action']['url'])
return response
elsif list.has_key?('dialog')
throw list['dialog']['explanation']
end
File.open("#{id}.html", 'w') {|f| f.write(response) }
throw "The feed was either empty, or mal-formed."
end
end
end

0 comments on commit a6958ae

Please sign in to comment.