Skip to content

Commit 10c5b5a

Browse files
authored
Merge pull request #157 from ruby/remove-userinfo-v0-11
Remove userinfo for v0.11.x
2 parents 5880a5f + 4aeb1f2 commit 10c5b5a

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ jobs:
77
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
88
strategy:
99
matrix:
10-
ruby: [ '3.0', 2.7, 2.6, 2.5, 2.4, head ]
10+
ruby: [ 3.1, '3.0', 2.7, 2.6, 2.5, 2.4, head, truffleruby ]
1111
os: [ ubuntu-latest, macos-latest ]
12+
exclude:
13+
- ruby: 2.4
14+
os: macos-latest
15+
- ruby: 2.5
16+
os: macos-latest
1217
runs-on: ${{ matrix.os }}
1318
steps:
14-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
1520
- name: Set up Ruby
1621
uses: ruby/setup-ruby@v1
1722
with:
1823
ruby-version: ${{ matrix.ruby }}
19-
- name: Install dependencies
20-
run: bundle install
24+
- run: bundle install --jobs 4 --retry 3
2125
- name: Run test
2226
run: rake test

lib/uri/generic.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,17 +1123,16 @@ def merge(oth)
11231123
base.fragment=(nil)
11241124

11251125
# RFC2396, Section 5.2, 4)
1126-
if !authority
1127-
base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path
1128-
else
1129-
# RFC2396, Section 5.2, 4)
1130-
base.set_path(rel.path) if rel.path
1126+
if authority
1127+
base.set_userinfo(rel.userinfo)
1128+
base.set_host(rel.host)
1129+
base.set_port(rel.port || base.default_port)
1130+
base.set_path(rel.path)
1131+
elsif base.path && rel.path
1132+
base.set_path(merge_path(base.path, rel.path))
11311133
end
11321134

11331135
# RFC2396, Section 5.2, 7)
1134-
base.set_userinfo(rel.userinfo) if rel.userinfo
1135-
base.set_host(rel.host) if rel.host
1136-
base.set_port(rel.port) if rel.port
11371136
base.query = rel.query if rel.query
11381137
base.fragment=(rel.fragment) if rel.fragment
11391138

test/uri/test_generic.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ def test_parse
157157
assert_equal(nil, url.user)
158158
assert_equal(nil, url.password)
159159
assert_equal(nil, url.userinfo)
160+
161+
# sec-2957667
162+
url = URI.parse('http://user:[email protected]').merge('//example.net')
163+
assert_equal('http://example.net', url.to_s)
164+
assert_nil(url.userinfo)
165+
url = URI.join('http://user:[email protected]', '//example.net')
166+
assert_equal('http://example.net', url.to_s)
167+
assert_nil(url.userinfo)
168+
url = URI.parse('http://user:[email protected]') + '//example.net'
169+
assert_equal('http://example.net', url.to_s)
170+
assert_nil(url.userinfo)
160171
end
161172

162173
def test_parse_scheme_with_symbols
@@ -249,6 +260,13 @@ def test_merge
249260
assert_equal(u0, u1)
250261
end
251262

263+
def test_merge_authority
264+
u = URI.parse('http://user:[email protected]:8080')
265+
u0 = URI.parse('http://new.example.org/path')
266+
u1 = u.merge('//new.example.org/path')
267+
assert_equal(u0, u1)
268+
end
269+
252270
def test_route
253271
url = URI.parse('http://hoge/a.html').route_to('http://hoge/b.html')
254272
assert_equal('b.html', url.to_s)

0 commit comments

Comments
 (0)