Skip to content

Commit da4a289

Browse files
authored
Merge pull request #9031 from ruby/uri-1-0-4
Bump up vendored URI to 1.0.4
2 parents f22a1a9 + 3946be0 commit da4a289

File tree

8 files changed

+50
-24
lines changed

8 files changed

+50
-24
lines changed

bundler/lib/bundler/vendor/uri/lib/uri/generic.rb

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,18 @@ def initialize(scheme,
186186

187187
if arg_check
188188
self.scheme = scheme
189-
self.userinfo = userinfo
190189
self.hostname = host
191190
self.port = port
191+
self.userinfo = userinfo
192192
self.path = path
193193
self.query = query
194194
self.opaque = opaque
195195
self.fragment = fragment
196196
else
197197
self.set_scheme(scheme)
198-
self.set_userinfo(userinfo)
199198
self.set_host(host)
200199
self.set_port(port)
200+
self.set_userinfo(userinfo)
201201
self.set_path(path)
202202
self.query = query
203203
self.set_opaque(opaque)
@@ -511,7 +511,7 @@ def set_userinfo(user, password = nil)
511511
user, password = split_userinfo(user)
512512
end
513513
@user = user
514-
@password = password if password
514+
@password = password
515515

516516
[@user, @password]
517517
end
@@ -522,7 +522,7 @@ def set_userinfo(user, password = nil)
522522
# See also Bundler::URI::Generic.user=.
523523
#
524524
def set_user(v)
525-
set_userinfo(v, @password)
525+
set_userinfo(v, nil)
526526
v
527527
end
528528
protected :set_user
@@ -574,6 +574,12 @@ def password
574574
@password
575575
end
576576

577+
# Returns the authority info (array of user, password, host and
578+
# port), if any is set. Or returns +nil+.
579+
def authority
580+
return @user, @password, @host, @port if @user || @password || @host || @port
581+
end
582+
577583
# Returns the user component after Bundler::URI decoding.
578584
def decoded_user
579585
Bundler::URI.decode_uri_component(@user) if @user
@@ -615,6 +621,13 @@ def set_host(v)
615621
end
616622
protected :set_host
617623

624+
# Protected setter for the authority info (+user+, +password+, +host+
625+
# and +port+). If +port+ is +nil+, +default_port+ will be set.
626+
#
627+
protected def set_authority(user, password, host, port = nil)
628+
@user, @password, @host, @port = user, password, host, port || self.default_port
629+
end
630+
618631
#
619632
# == Args
620633
#
@@ -639,6 +652,7 @@ def set_host(v)
639652
def host=(v)
640653
check_host(v)
641654
set_host(v)
655+
set_userinfo(nil)
642656
v
643657
end
644658

@@ -729,6 +743,7 @@ def set_port(v)
729743
def port=(v)
730744
check_port(v)
731745
set_port(v)
746+
set_userinfo(nil)
732747
port
733748
end
734749

@@ -1121,7 +1136,7 @@ def merge(oth)
11211136

11221137
base = self.dup
11231138

1124-
authority = rel.userinfo || rel.host || rel.port
1139+
authority = rel.authority
11251140

11261141
# RFC2396, Section 5.2, 2)
11271142
if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
@@ -1134,9 +1149,7 @@ def merge(oth)
11341149

11351150
# RFC2396, Section 5.2, 4)
11361151
if authority
1137-
base.set_userinfo(rel.userinfo)
1138-
base.set_host(rel.host)
1139-
base.set_port(rel.port || base.default_port)
1152+
base.set_authority(*authority)
11401153
base.set_path(rel.path)
11411154
elsif base.path && rel.path
11421155
base.set_path(merge_path(base.path, rel.path))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Bundler::URI
22
# :stopdoc:
3-
VERSION_CODE = '010003'.freeze
3+
VERSION_CODE = '010004'.freeze
44
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
55
# :startdoc:
66
end

lib/rubygems/vendor/uri/lib/uri/generic.rb

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,18 @@ def initialize(scheme,
186186

187187
if arg_check
188188
self.scheme = scheme
189-
self.userinfo = userinfo
190189
self.hostname = host
191190
self.port = port
191+
self.userinfo = userinfo
192192
self.path = path
193193
self.query = query
194194
self.opaque = opaque
195195
self.fragment = fragment
196196
else
197197
self.set_scheme(scheme)
198-
self.set_userinfo(userinfo)
199198
self.set_host(host)
200199
self.set_port(port)
200+
self.set_userinfo(userinfo)
201201
self.set_path(path)
202202
self.query = query
203203
self.set_opaque(opaque)
@@ -511,7 +511,7 @@ def set_userinfo(user, password = nil)
511511
user, password = split_userinfo(user)
512512
end
513513
@user = user
514-
@password = password if password
514+
@password = password
515515

516516
[@user, @password]
517517
end
@@ -522,7 +522,7 @@ def set_userinfo(user, password = nil)
522522
# See also Gem::URI::Generic.user=.
523523
#
524524
def set_user(v)
525-
set_userinfo(v, @password)
525+
set_userinfo(v, nil)
526526
v
527527
end
528528
protected :set_user
@@ -574,6 +574,12 @@ def password
574574
@password
575575
end
576576

577+
# Returns the authority info (array of user, password, host and
578+
# port), if any is set. Or returns +nil+.
579+
def authority
580+
return @user, @password, @host, @port if @user || @password || @host || @port
581+
end
582+
577583
# Returns the user component after Gem::URI decoding.
578584
def decoded_user
579585
Gem::URI.decode_uri_component(@user) if @user
@@ -615,6 +621,13 @@ def set_host(v)
615621
end
616622
protected :set_host
617623

624+
# Protected setter for the authority info (+user+, +password+, +host+
625+
# and +port+). If +port+ is +nil+, +default_port+ will be set.
626+
#
627+
protected def set_authority(user, password, host, port = nil)
628+
@user, @password, @host, @port = user, password, host, port || self.default_port
629+
end
630+
618631
#
619632
# == Args
620633
#
@@ -639,6 +652,7 @@ def set_host(v)
639652
def host=(v)
640653
check_host(v)
641654
set_host(v)
655+
set_userinfo(nil)
642656
v
643657
end
644658

@@ -729,6 +743,7 @@ def set_port(v)
729743
def port=(v)
730744
check_port(v)
731745
set_port(v)
746+
set_userinfo(nil)
732747
port
733748
end
734749

@@ -1121,7 +1136,7 @@ def merge(oth)
11211136

11221137
base = self.dup
11231138

1124-
authority = rel.userinfo || rel.host || rel.port
1139+
authority = rel.authority
11251140

11261141
# RFC2396, Section 5.2, 2)
11271142
if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
@@ -1134,9 +1149,7 @@ def merge(oth)
11341149

11351150
# RFC2396, Section 5.2, 4)
11361151
if authority
1137-
base.set_userinfo(rel.userinfo)
1138-
base.set_host(rel.host)
1139-
base.set_port(rel.port || base.default_port)
1152+
base.set_authority(*authority)
11401153
base.set_path(rel.path)
11411154
elsif base.path && rel.path
11421155
base.set_path(merge_path(base.path, rel.path))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Gem::URI
22
# :stopdoc:
3-
VERSION_CODE = '010003'.freeze
3+
VERSION_CODE = '010004'.freeze
44
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
55
# :startdoc:
66
end

test/rubygems/test_gem_request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def test_fetch_basic_oauth_encoded
248248

249249
auth_header = conn.payload["Authorization"]
250250
assert_equal "Basic #{base64_encode64("{DEScede}pass:x-oauth-basic")}".strip, auth_header
251-
assert_includes @ui.output, "GET https://REDACTED:x-oauth-basic@example.rubygems/specs.#{Gem.marshal_version}"
251+
assert_includes @ui.output, "GET https://REDACTED@example.rubygems/specs.#{Gem.marshal_version}"
252252
end
253253

254254
def test_fetch_head

test/rubygems/test_gem_uri.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_redacted_with_token
2121
end
2222

2323
def test_redacted_with_user_x_oauth_basic
24-
assert_equal "https://REDACTED:x-oauth-basic@example.com", Gem::Uri.new("https://token:x-oauth-basic@example.com").redacted.to_s
24+
assert_equal "https://REDACTED@example.com", Gem::Uri.new("https://token:x-oauth-basic@example.com").redacted.to_s
2525
end
2626

2727
def test_redacted_without_credential

tool/bundler/vendor_gems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
gem "timeout", "0.4.3"
1515
gem "thor", "1.4.0"
1616
gem "tsort", "0.2.0"
17-
gem "uri", "1.0.3"
17+
gem "uri", "1.0.4"

tool/bundler/vendor_gems.rb.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ GEM
4040
thor (1.4.0)
4141
timeout (0.4.3)
4242
tsort (0.2.0)
43-
uri (1.0.3)
43+
uri (1.0.4)
4444

4545
PLATFORMS
4646
java
@@ -64,7 +64,7 @@ DEPENDENCIES
6464
thor (= 1.4.0)
6565
timeout (= 0.4.3)
6666
tsort (= 0.2.0)
67-
uri (= 1.0.3)
67+
uri (= 1.0.4)
6868

6969
CHECKSUMS
7070
connection_pool (2.5.0) sha256=233b92f8d38e038c1349ccea65dd3772727d669d6d2e71f9897c8bf5cd53ebfc
@@ -80,7 +80,7 @@ CHECKSUMS
8080
thor (1.4.0) sha256=8763e822ccb0f1d7bee88cde131b19a65606657b847cc7b7b4b82e772bcd8a3d
8181
timeout (0.4.3) sha256=9509f079b2b55fe4236d79633bd75e34c1c1e7e3fb4b56cb5fda61f80a0fe30e
8282
tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
83-
uri (1.0.3) sha256=e9f2244608eea2f7bc357d954c65c910ce0399ca5e18a7a29207ac22d8767011
83+
uri (1.0.4) sha256=34485d137c079f8753a0ca1d883841a7ba2e5fae556e3c30c2aab0dde616344b
8484

8585
BUNDLED WITH
8686
4.0.0.dev

0 commit comments

Comments
 (0)