summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--lib/open-uri.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index db17a8d859..7ab59950fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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