зеркало из https://github.com/github/ruby.git
Guard for the ftp protocol feature of OpenURI
This commit is contained in:
Родитель
b8dcad8d32
Коммит
350bc29107
|
@ -750,7 +750,12 @@ module URI
|
|||
OpenURI.open_http(buf, self, proxy, options)
|
||||
return
|
||||
end
|
||||
|
||||
begin
|
||||
require 'net/ftp'
|
||||
rescue LoadError
|
||||
abort "net/ftp is not found. You may need to `gem install net-ftp` to install net/ftp."
|
||||
end
|
||||
|
||||
path = self.path
|
||||
path = path.sub(%r{\A/}, '%2F') # re-encode the beginning slash because uri library decodes it.
|
||||
|
|
|
@ -703,6 +703,9 @@ class TestOpenURI < Test::Unit::TestCase
|
|||
|
||||
# 192.0.2.0/24 is TEST-NET. [RFC3330]
|
||||
|
||||
begin
|
||||
require 'net/ftp'
|
||||
|
||||
def test_ftp_invalid_request
|
||||
assert_raise(ArgumentError) { URI("ftp://127.0.0.1/").read }
|
||||
assert_raise(ArgumentError) { URI("ftp://127.0.0.1/a%0Db").read }
|
||||
|
@ -841,6 +844,9 @@ class TestOpenURI < Test::Unit::TestCase
|
|||
end
|
||||
}
|
||||
end
|
||||
rescue LoadError
|
||||
# net-ftp is the bundled gems at Ruby 3.1
|
||||
end
|
||||
|
||||
def test_ftp_over_http_proxy
|
||||
TCPServer.open("127.0.0.1", 0) {|proxy_serv|
|
||||
|
|
Загрузка…
Ссылка в новой задаче