diff options
| author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2025-02-26 18:14:16 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2025-03-08 16:27:22 +0900 |
| commit | e58827163002e816e49ed18007f4fa3481102b08 (patch) | |
| tree | b3141c203945a17d9016bcc6c4bea066e9442fce | |
| parent | 188ff4d4356b1a369e2204e5c45e1d168ffdf631 (diff) | |
Merge uri-0.13.2
| -rw-r--r-- | lib/uri/generic.rb | 15 | ||||
| -rw-r--r-- | lib/uri/version.rb | 2 | ||||
| -rw-r--r-- | test/uri/test_generic.rb | 18 |
3 files changed, 26 insertions, 9 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index f3540a24bb..2c0a88da5d 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1133,17 +1133,16 @@ module URI base.fragment=(nil) # RFC2396, Section 5.2, 4) - if !authority - base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path - else - # RFC2396, Section 5.2, 4) - base.set_path(rel.path) if rel.path + if authority + base.set_userinfo(rel.userinfo) + base.set_host(rel.host) + base.set_port(rel.port || base.default_port) + base.set_path(rel.path) + elsif base.path && rel.path + base.set_path(merge_path(base.path, rel.path)) end # RFC2396, Section 5.2, 7) - base.set_userinfo(rel.userinfo) if rel.userinfo - base.set_host(rel.host) if rel.host - base.set_port(rel.port) if rel.port base.query = rel.query if rel.query base.fragment=(rel.fragment) if rel.fragment diff --git a/lib/uri/version.rb b/lib/uri/version.rb index bfe3f47670..962f09a3e6 100644 --- a/lib/uri/version.rb +++ b/lib/uri/version.rb @@ -1,6 +1,6 @@ module URI # :stopdoc: - VERSION_CODE = '001301'.freeze + VERSION_CODE = '001302'.freeze VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze # :startdoc: end diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index e6619373c6..1a70dd42c4 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -164,6 +164,17 @@ class URI::TestGeneric < Test::Unit::TestCase # must be empty string to identify as path-abempty, not path-absolute assert_equal('', url.host) assert_equal('http:////example.com', url.to_s) + + # sec-2957667 + url = URI.parse('http://user:pass@example.com').merge('//example.net') + assert_equal('http://example.net', url.to_s) + assert_nil(url.userinfo) + url = URI.join('http://user:pass@example.com', '//example.net') + assert_equal('http://example.net', url.to_s) + assert_nil(url.userinfo) + url = URI.parse('http://user:pass@example.com') + '//example.net' + assert_equal('http://example.net', url.to_s) + assert_nil(url.userinfo) end def test_parse_scheme_with_symbols @@ -256,6 +267,13 @@ class URI::TestGeneric < Test::Unit::TestCase assert_equal(u0, u1) end + def test_merge_authority + u = URI.parse('http://user:pass@example.com:8080') + u0 = URI.parse('http://new.example.org/path') + u1 = u.merge('//new.example.org/path') + assert_equal(u0, u1) + end + def test_route url = URI.parse('http://hoge/a.html').route_to('http://hoge/b.html') assert_equal('b.html', url.to_s) |
