Guard for the ftp protocol feature of OpenURI
This commit is contained in:
parent
b8dcad8d32
commit
350bc29107
Notes:
git
2021-05-27 14:42:36 +09:00
@ -750,7 +750,12 @@ module URI
|
|||||||
OpenURI.open_http(buf, self, proxy, options)
|
OpenURI.open_http(buf, self, proxy, options)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
require 'net/ftp'
|
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 = self.path
|
||||||
path = path.sub(%r{\A/}, '%2F') # re-encode the beginning slash because uri library decodes it.
|
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]
|
# 192.0.2.0/24 is TEST-NET. [RFC3330]
|
||||||
|
|
||||||
|
begin
|
||||||
|
require 'net/ftp'
|
||||||
|
|
||||||
def test_ftp_invalid_request
|
def test_ftp_invalid_request
|
||||||
assert_raise(ArgumentError) { URI("ftp://127.0.0.1/").read }
|
assert_raise(ArgumentError) { URI("ftp://127.0.0.1/").read }
|
||||||
assert_raise(ArgumentError) { URI("ftp://127.0.0.1/a%0Db").read }
|
assert_raise(ArgumentError) { URI("ftp://127.0.0.1/a%0Db").read }
|
||||||
@ -841,6 +844,9 @@ class TestOpenURI < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
rescue LoadError
|
||||||
|
# net-ftp is the bundled gems at Ruby 3.1
|
||||||
|
end
|
||||||
|
|
||||||
def test_ftp_over_http_proxy
|
def test_ftp_over_http_proxy
|
||||||
TCPServer.open("127.0.0.1", 0) {|proxy_serv|
|
TCPServer.open("127.0.0.1", 0) {|proxy_serv|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user