From d7f5015ab9d1507913b8cb60305a65cc565f93a7 Mon Sep 17 00:00:00 2001 From: yugui Date: Sat, 31 Oct 2009 13:05:54 +0000 Subject: merges r24865,r24866,r24869,r24872,r24875,r24876 and r24877 from trunk into ruby_1_9_1. -- * lib/open-uri.rb (URI::FTP#buffer_open): use the port specified in the URI. -- test ftp over http proxy. -- fix tests. -- test invalid redirect location. -- * lib/open-uri.rb (URI::FTP#buffer_open): fix the %2F handling. -- test read_timeout. -- extra commas removed. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@25600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/open-uri.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 2a6c544fe..b426455e2 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -778,8 +778,9 @@ module URI end require 'net/ftp' - directories = self.path.split(%r{/}, -1) - directories.shift if directories[0] == '' # strip a field before leading slash + path = self.path + path = path.sub(%r{\A/}, '%2F') # re-encode the beginning slash because uri library decodes it. + directories = path.split(%r{/}, -1) directories.each {|d| d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") } } @@ -800,7 +801,8 @@ module URI end # The access sequence is defined by RFC 1738 - ftp = Net::FTP.open(self.host) + ftp = Net::FTP.new + ftp.connect(self.host, self.port) ftp.passive = true if !options[:ftp_active_mode] # todo: extract user/passwd from .netrc. user = 'anonymous' -- cgit