diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-08 13:11:46 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-08 13:11:46 +0000 |
commit | 54b455190b9ed9200436d9bd4967dd272576d0b7 (patch) | |
tree | 7cfc575691b4ce06d3a4419fa6342bdc77441bd2 /lib/open-uri.rb | |
parent | ef816db96f1ec52a537a7623b476639291483fc2 (diff) | |
download | ruby-54b455190b9ed9200436d9bd4967dd272576d0b7.tar.gz |
* lib/open-uri.rb (OpenURI.open_http): rescue URI::InvalidURIError by
URI.parse for location URI.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/open-uri.rb')
-rw-r--r-- | lib/open-uri.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 2b6cd8fd65..64b78b1217 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -330,7 +330,12 @@ module OpenURI Net::HTTPFound, # 302 Net::HTTPSeeOther, # 303 Net::HTTPTemporaryRedirect # 307 - throw :open_uri_redirect, URI.parse(resp['location']) + begin + loc_uri = URI.parse(resp['location']) + rescue URI::InvalidURIError + raise OpenURI::HTTPError.new(io.status.join(' ') + ' (Invalid Location URI)', io) + end + throw :open_uri_redirect, loc_uri else raise OpenURI::HTTPError.new(io.status.join(' '), io) end |