Skip to content

Commit bb6a3ed

Browse files
deivid-rodriguezhsbt
authored andcommitted
Bump vendored uri to 1.0.1
1 parent 1b137a9 commit bb6a3ed

File tree

19 files changed

+207
-128
lines changed

19 files changed

+207
-128
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: false
22
# Bundler::URI is a module providing classes to handle Uniform Resource Identifiers
3-
# (RFC2396[http://tools.ietf.org/html/rfc2396]).
3+
# (RFC2396[https://www.rfc-editor.org/rfc/rfc2396]).
44
#
55
# == Features
66
#
@@ -47,14 +47,14 @@
4747
# A good place to view an RFC spec is http://www.ietf.org/rfc.html.
4848
#
4949
# Here is a list of all related RFC's:
50-
# - RFC822[http://tools.ietf.org/html/rfc822]
51-
# - RFC1738[http://tools.ietf.org/html/rfc1738]
52-
# - RFC2255[http://tools.ietf.org/html/rfc2255]
53-
# - RFC2368[http://tools.ietf.org/html/rfc2368]
54-
# - RFC2373[http://tools.ietf.org/html/rfc2373]
55-
# - RFC2396[http://tools.ietf.org/html/rfc2396]
56-
# - RFC2732[http://tools.ietf.org/html/rfc2732]
57-
# - RFC3986[http://tools.ietf.org/html/rfc3986]
50+
# - RFC822[https://www.rfc-editor.org/rfc/rfc822]
51+
# - RFC1738[https://www.rfc-editor.org/rfc/rfc1738]
52+
# - RFC2255[https://www.rfc-editor.org/rfc/rfc2255]
53+
# - RFC2368[https://www.rfc-editor.org/rfc/rfc2368]
54+
# - RFC2373[https://www.rfc-editor.org/rfc/rfc2373]
55+
# - RFC2396[https://www.rfc-editor.org/rfc/rfc2396]
56+
# - RFC2732[https://www.rfc-editor.org/rfc/rfc2732]
57+
# - RFC3986[https://www.rfc-editor.org/rfc/rfc3986]
5858
#
5959
# == Class tree
6060
#

lib/bundler/vendor/uri/lib/uri/common.rb

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,52 @@
1313
require_relative "rfc3986_parser"
1414

1515
module Bundler::URI
16-
include RFC2396_REGEXP
16+
RFC2396_PARSER = RFC2396_Parser.new
17+
Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
1718

18-
REGEXP = RFC2396_REGEXP
19-
Parser = RFC2396_Parser
2019
RFC3986_PARSER = RFC3986_Parser.new
2120
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
22-
RFC2396_PARSER = RFC2396_Parser.new
23-
Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
2421

25-
# Bundler::URI::Parser.new
26-
DEFAULT_PARSER = Parser.new
27-
DEFAULT_PARSER.pattern.each_pair do |sym, str|
28-
unless REGEXP::PATTERN.const_defined?(sym)
29-
REGEXP::PATTERN.const_set(sym, str)
22+
DEFAULT_PARSER = RFC3986_PARSER
23+
Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
24+
25+
def self.parser=(parser = RFC3986_PARSER)
26+
remove_const(:Parser) if defined?(::Bundler::URI::Parser)
27+
const_set("Parser", parser.class)
28+
29+
remove_const(:REGEXP) if defined?(::Bundler::URI::REGEXP)
30+
remove_const(:PATTERN) if defined?(::Bundler::URI::PATTERN)
31+
if Parser == RFC2396_Parser
32+
const_set("REGEXP", Bundler::URI::RFC2396_REGEXP)
33+
const_set("PATTERN", Bundler::URI::RFC2396_REGEXP::PATTERN)
34+
Parser.new.pattern.each_pair do |sym, str|
35+
unless REGEXP::PATTERN.const_defined?(sym)
36+
REGEXP::PATTERN.const_set(sym, str)
37+
end
38+
end
39+
end
40+
41+
Parser.new.regexp.each_pair do |sym, str|
42+
remove_const(sym) if const_defined?(sym)
43+
const_set(sym, str)
3044
end
3145
end
32-
DEFAULT_PARSER.regexp.each_pair do |sym, str|
33-
const_set(sym, str)
46+
self.parser = RFC3986_PARSER
47+
48+
def self.const_missing(const)
49+
if const == :REGEXP
50+
warn "Bundler::URI::REGEXP is obsolete. Use Bundler::URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
51+
Bundler::URI::RFC2396_REGEXP
52+
elsif value = RFC2396_PARSER.regexp[const]
53+
warn "Bundler::URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
54+
value
55+
elsif value = RFC2396_Parser.const_get(const)
56+
warn "Bundler::URI::#{const} is obsolete. Use RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
57+
value
58+
else
59+
super
60+
end
3461
end
35-
Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
3662

3763
module Util # :nodoc:
3864
def make_components_hash(klass, array_hash)
@@ -170,7 +196,7 @@ class BadURIError < Error; end
170196
# ["fragment", "top"]]
171197
#
172198
def self.split(uri)
173-
RFC3986_PARSER.split(uri)
199+
DEFAULT_PARSER.split(uri)
174200
end
175201

176202
# Returns a new \Bundler::URI object constructed from the given string +uri+:
@@ -184,7 +210,7 @@ def self.split(uri)
184210
# if it may contain invalid Bundler::URI characters.
185211
#
186212
def self.parse(uri)
187-
RFC3986_PARSER.parse(uri)
213+
DEFAULT_PARSER.parse(uri)
188214
end
189215

190216
# Merges the given Bundler::URI strings +str+
@@ -211,7 +237,7 @@ def self.parse(uri)
211237
# # => #<Bundler::URI::HTTP http://example.com/foo/bar>
212238
#
213239
def self.join(*str)
214-
RFC3986_PARSER.join(*str)
240+
DEFAULT_PARSER.join(*str)
215241
end
216242

217243
#

lib/bundler/vendor/uri/lib/uri/file.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ def set_port(v)
7070

7171
# raise InvalidURIError
7272
def check_userinfo(user)
73-
raise Bundler::URI::InvalidURIError, "can not set userinfo for file Bundler::URI"
73+
raise Bundler::URI::InvalidURIError, "cannot set userinfo for file Bundler::URI"
7474
end
7575

7676
# raise InvalidURIError
7777
def check_user(user)
78-
raise Bundler::URI::InvalidURIError, "can not set user for file Bundler::URI"
78+
raise Bundler::URI::InvalidURIError, "cannot set user for file Bundler::URI"
7979
end
8080

8181
# raise InvalidURIError
8282
def check_password(user)
83-
raise Bundler::URI::InvalidURIError, "can not set password for file Bundler::URI"
83+
raise Bundler::URI::InvalidURIError, "cannot set password for file Bundler::URI"
8484
end
8585

8686
# do nothing

lib/bundler/vendor/uri/lib/uri/ftp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Bundler::URI
1717
# This class will be redesigned because of difference of implementations;
1818
# the structure of its path. draft-hoffman-ftp-uri-04 is a draft but it
1919
# is a good summary about the de facto spec.
20-
# http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
20+
# https://datatracker.ietf.org/doc/html/draft-hoffman-ftp-uri-04
2121
#
2222
class FTP < Generic
2323
# A Default port of 21 for Bundler::URI::FTP.

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

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def self.build2(args)
8282
if args.kind_of?(Array)
8383
return self.build(args.collect{|x|
8484
if x.is_a?(String)
85-
DEFAULT_PARSER.escape(x)
85+
Bundler::URI::RFC2396_PARSER.escape(x)
8686
else
8787
x
8888
end
@@ -91,7 +91,7 @@ def self.build2(args)
9191
tmp = {}
9292
args.each do |key, value|
9393
tmp[key] = if value
94-
DEFAULT_PARSER.escape(value)
94+
Bundler::URI::RFC2396_PARSER.escape(value)
9595
else
9696
value
9797
end
@@ -393,7 +393,7 @@ def check_userinfo(user, password = nil)
393393
def check_user(v)
394394
if @opaque
395395
raise InvalidURIError,
396-
"can not set user with opaque"
396+
"cannot set user with opaque"
397397
end
398398

399399
return v unless v
@@ -417,7 +417,7 @@ def check_user(v)
417417
def check_password(v, user = @user)
418418
if @opaque
419419
raise InvalidURIError,
420-
"can not set password with opaque"
420+
"cannot set password with opaque"
421421
end
422422
return v unless v
423423

@@ -596,7 +596,7 @@ def check_host(v)
596596

597597
if @opaque
598598
raise InvalidURIError,
599-
"can not set host with registry or opaque"
599+
"cannot set host with registry or opaque"
600600
elsif parser.regexp[:HOST] !~ v
601601
raise InvalidComponentError,
602602
"bad component(expected host component): #{v}"
@@ -685,7 +685,7 @@ def check_port(v)
685685

686686
if @opaque
687687
raise InvalidURIError,
688-
"can not set port with registry or opaque"
688+
"cannot set port with registry or opaque"
689689
elsif !v.kind_of?(Integer) && parser.regexp[:PORT] !~ v
690690
raise InvalidComponentError,
691691
"bad component(expected port component): #{v.inspect}"
@@ -733,17 +733,17 @@ def port=(v)
733733
end
734734

735735
def check_registry(v) # :nodoc:
736-
raise InvalidURIError, "can not set registry"
736+
raise InvalidURIError, "cannot set registry"
737737
end
738738
private :check_registry
739739

740740
def set_registry(v) #:nodoc:
741-
raise InvalidURIError, "can not set registry"
741+
raise InvalidURIError, "cannot set registry"
742742
end
743743
protected :set_registry
744744

745745
def registry=(v)
746-
raise InvalidURIError, "can not set registry"
746+
raise InvalidURIError, "cannot set registry"
747747
end
748748

749749
#
@@ -866,7 +866,7 @@ def check_opaque(v)
866866
# hier_part = ( net_path | abs_path ) [ "?" query ]
867867
if @host || @port || @user || @path # userinfo = @user + ':' + @password
868868
raise InvalidURIError,
869-
"can not set opaque with host, port, userinfo or path"
869+
"cannot set opaque with host, port, userinfo or path"
870870
elsif v && parser.regexp[:OPAQUE] !~ v
871871
raise InvalidComponentError,
872872
"bad component(expected opaque component): #{v}"
@@ -945,7 +945,7 @@ def fragment=(v)
945945
# == Description
946946
#
947947
# Bundler::URI has components listed in order of decreasing significance from left to right,
948-
# see RFC3986 https://tools.ietf.org/html/rfc3986 1.2.3.
948+
# see RFC3986 https://www.rfc-editor.org/rfc/rfc3986 1.2.3.
949949
#
950950
# == Usage
951951
#
@@ -1235,7 +1235,7 @@ def route_from0(oth)
12351235
return rel, rel
12361236
end
12371237

1238-
# you can modify `rel', but can not `oth'.
1238+
# you can modify `rel', but cannot `oth'.
12391239
return oth, rel
12401240
end
12411241
private :route_from0
@@ -1260,7 +1260,7 @@ def route_from0(oth)
12601260
# #=> #<Bundler::URI::Generic /main.rbx?page=1>
12611261
#
12621262
def route_from(oth)
1263-
# you can modify `rel', but can not `oth'.
1263+
# you can modify `rel', but cannot `oth'.
12641264
begin
12651265
oth, rel = route_from0(oth)
12661266
rescue
@@ -1364,6 +1364,9 @@ def to_s
13641364
str << ':'
13651365
str << @port.to_s
13661366
end
1367+
if (@host || @port) && !@path.empty? && !@path.start_with?('/')
1368+
str << '/'
1369+
end
13671370
str << @path
13681371
if @query
13691372
str << '?'
@@ -1399,19 +1402,6 @@ def eql?(oth)
13991402
self.component_ary.eql?(oth.component_ary)
14001403
end
14011404

1402-
=begin
1403-
1404-
--- Bundler::URI::Generic#===(oth)
1405-
1406-
=end
1407-
# def ===(oth)
1408-
# raise NotImplementedError
1409-
# end
1410-
1411-
=begin
1412-
=end
1413-
1414-
14151405
# Returns an Array of the components defined from the COMPONENT Array.
14161406
def component_ary
14171407
component.collect do |x|

lib/bundler/vendor/uri/lib/uri/http.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def request_uri
8585
# == Description
8686
#
8787
# Returns the authority for an HTTP uri, as defined in
88-
# https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
88+
# https://www.rfc-editor.org/rfc/rfc3986#section-3.2.
8989
#
9090
#
9191
# Example:
@@ -106,7 +106,7 @@ def authority
106106
# == Description
107107
#
108108
# Returns the origin for an HTTP uri, as defined in
109-
# https://datatracker.ietf.org/doc/html/rfc6454.
109+
# https://www.rfc-editor.org/rfc/rfc6454.
110110
#
111111
#
112112
# Example:

lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ def split(uri)
140140

141141
if !scheme
142142
raise InvalidURIError,
143-
"bad Bundler::URI(absolute but no scheme): #{uri}"
143+
"bad Bundler::URI (absolute but no scheme): #{uri}"
144144
end
145145
if !opaque && (!path && (!host && !registry))
146146
raise InvalidURIError,
147-
"bad Bundler::URI(absolute but no path): #{uri}"
147+
"bad Bundler::URI (absolute but no path): #{uri}"
148148
end
149149

150150
when @regexp[:REL_URI]
@@ -173,7 +173,7 @@ def split(uri)
173173
# server = [ [ userinfo "@" ] hostport ]
174174

175175
else
176-
raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri}"
176+
raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri}"
177177
end
178178

179179
path = '' if !path && !opaque # (see RFC2396 Section 5.2)

lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def split(uri) #:nodoc:
7878
begin
7979
uri = uri.to_str
8080
rescue NoMethodError
81-
raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri.inspect}"
81+
raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri.inspect}"
8282
end
8383
uri.ascii_only? or
8484
raise InvalidURIError, "Bundler::URI must be ascii only #{uri.dump}"
@@ -127,20 +127,43 @@ def split(uri) #:nodoc:
127127
m["fragment"]
128128
]
129129
else
130-
raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri.inspect}"
130+
raise InvalidURIError, "bad Bundler::URI (is not Bundler::URI?): #{uri.inspect}"
131131
end
132132
end
133133

134134
def parse(uri) # :nodoc:
135135
Bundler::URI.for(*self.split(uri), self)
136136
end
137137

138-
139138
def join(*uris) # :nodoc:
140139
uris[0] = convert_to_uri(uris[0])
141140
uris.inject :merge
142141
end
143142

143+
# Compatibility for RFC2396 parser
144+
def extract(str, schemes = nil, &block) # :nodoc:
145+
warn "Bundler::URI::RFC3986_PARSER.extract is obsoleted. Use Bundler::URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE
146+
RFC2396_PARSER.extract(str, schemes, &block)
147+
end
148+
149+
# Compatibility for RFC2396 parser
150+
def make_regexp(schemes = nil) # :nodoc:
151+
warn "Bundler::URI::RFC3986_PARSER.make_regexp is obsoleted. Use Bundler::URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE
152+
RFC2396_PARSER.make_regexp(schemes)
153+
end
154+
155+
# Compatibility for RFC2396 parser
156+
def escape(str, unsafe = nil) # :nodoc:
157+
warn "Bundler::URI::RFC3986_PARSER.escape is obsoleted. Use Bundler::URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE
158+
unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str)
159+
end
160+
161+
# Compatibility for RFC2396 parser
162+
def unescape(str, escaped = nil) # :nodoc:
163+
warn "Bundler::URI::RFC3986_PARSER.unescape is obsoleted. Use Bundler::URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE
164+
escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str)
165+
end
166+
144167
@@to_s = Kernel.instance_method(:to_s)
145168
if @@to_s.respond_to?(:bind_call)
146169
def inspect
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 = '001301'.freeze
3+
VERSION_CODE = '010001'.freeze
44
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
55
# :startdoc:
66
end

0 commit comments

Comments
 (0)