diff options
| author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-09 03:16:49 +0000 |
|---|---|---|
| committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-09 03:16:49 +0000 |
| commit | 89f7a63db46f5821c629fa55dc45ade148b0e366 (patch) | |
| tree | b0395399a9dff9fba875761c331fdbae95e379d6 | |
| parent | 133156e30e50d937718f117ab3957ddc2db84e29 (diff) | |
r22165@crimson: knu | 2009-02-09 11:55:30 +0900
(OpenURI.open_http): rescue URI::InvalidURIError by URI.parse
for location URI. (r15406)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@22158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 2 | ||||
| -rw-r--r-- | lib/open-uri.rb | 7 |
2 files changed, 8 insertions, 1 deletions
@@ -17,6 +17,8 @@ Mon Feb 9 11:50:02 2009 Akinori MUSHA <knu@iDaemons.org> (OpenURI::Buffer): use Meta ===. [ruby-core:14295] (r14609) (OpenURI::Meta#content_type_parse): fix tests. [ruby-dev:33336] (r15200) + (OpenURI.open_http): rescue URI::InvalidURIError by URI.parse + for location URI. (r15406) Mon Feb 9 01:21:16 2009 Tanaka Akira <akr@fsij.org> diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 69232bf366..3132cd5593 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -327,7 +327,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 |
