summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-08 13:11:46 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-08 13:11:46 +0000
commit54b455190b9ed9200436d9bd4967dd272576d0b7 (patch)
tree7cfc575691b4ce06d3a4419fa6342bdc77441bd2
parentef816db96f1ec52a537a7623b476639291483fc2 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--lib/open-uri.rb7
2 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 7b589d8dad..29eece08f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Feb 8 22:10:36 2008 Tanaka Akira <akr@fsij.org>
+
+ * lib/open-uri.rb (OpenURI.open_http): rescue URI::InvalidURIError by
+ URI.parse for location URI.
+
Fri Feb 8 19:22:13 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv/iconv.c (rb_str_derive): uses rb_str_subseq() for byte
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