diff options
Diffstat (limited to 'test/uri/test_generic.rb')
-rw-r--r-- | test/uri/test_generic.rb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index d122587031..8209363b82 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -24,7 +24,19 @@ class URI::TestGeneric < Test::Unit::TestCase assert_equal "file:///foo", URI("file:///foo").to_s assert_equal "postgres:///foo", URI("postgres:///foo").to_s - assert_equal "http:/foo", URI("http:///foo").to_s + assert_equal "http:///foo", URI("http:///foo").to_s + assert_equal "http:/foo", URI("http:/foo").to_s + + uri = URI('rel_path') + assert_equal "rel_path", uri.to_s + uri.scheme = 'http' + assert_equal "http:rel_path", uri.to_s + uri.host = 'h' + assert_equal "http://h/rel_path", uri.to_s + uri.port = 8080 + assert_equal "http://h:8080/rel_path", uri.to_s + uri.host = nil + assert_equal "http::8080/rel_path", uri.to_s end def test_parse @@ -157,6 +169,19 @@ class URI::TestGeneric < Test::Unit::TestCase assert_equal(nil, url.user) assert_equal(nil, url.password) assert_equal(nil, url.userinfo) + + # sec-156615 + url = URI.parse('http:////example.com') + # must be empty string to identify as path-abempty, not path-absolute + assert_equal('', url.host) + assert_equal('http:////example.com', url.to_s) + end + + def test_parse_scheme_with_symbols + # Valid schemes from https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml + assert_equal 'ms-search', URI.parse('ms-search://localhost').scheme + assert_equal 'microsoft.windows.camera', URI.parse('microsoft.windows.camera://localhost').scheme + assert_equal 'coaps+ws', URI.parse('coaps+ws:localhost').scheme end def test_merge @@ -963,6 +988,10 @@ class URI::TestGeneric < Test::Unit::TestCase end end + def test_split + assert_equal [nil, nil, nil, nil, nil, "", nil, nil, nil], URI.split("//") + end + class CaseInsensitiveEnv def initialize(h={}) @h = {} |