From 5504f490a6a2684bcacadee836c6933243e65a4f Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 5 Feb 2003 09:58:18 +0000 Subject: [PATCH] * lib/open-uri.rb: Location: field may has a relative URI. pointed out by erik eriksson . git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/open-uri.rb | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d3144ee57b..8199b1cb55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Feb 5 18:54:54 2003 Tanaka Akira + + * lib/open-uri.rb: Location: field may has a relative URI. + pointed out by erik eriksson . + Wed Feb 5 17:11:02 2003 Yukihiro Matsumoto * parse.y (yylex): no . floating literal anymore. diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 2a72062574..e8cb3a24b2 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -130,7 +130,13 @@ module OpenURI uri.direct_open(buf, header) end rescue Redirect - uri = $!.uri + loc = $!.uri + if loc.relative? + # Although it violates RFC 2616, Location: field may have relative URI. + # It is converted to absolute URI using uri. + loc = uri + loc + end + uri = loc raise "HTTP redirection loop: #{uri}" if uri_set.include? uri.to_s uri_set[uri.to_s] = true retry