uri 0.10.2 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +4 -7
- data/Gemfile +1 -0
- data/README.md +3 -2
- data/lib/uri/common.rb +64 -16
- data/lib/uri/file.rb +7 -1
- data/lib/uri/ftp.rb +2 -1
- data/lib/uri/generic.rb +27 -7
- data/lib/uri/http.rb +40 -2
- data/lib/uri/https.rb +2 -1
- data/lib/uri/ldap.rb +1 -1
- data/lib/uri/ldaps.rb +2 -1
- data/lib/uri/mailto.rb +2 -2
- data/lib/uri/rfc2396_parser.rb +15 -9
- data/lib/uri/rfc3986_parser.rb +10 -5
- data/lib/uri/version.rb +1 -1
- data/lib/uri/ws.rb +1 -2
- data/lib/uri/wss.rb +2 -1
- data/lib/uri.rb +3 -2
- data/uri.gemspec +2 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e148d563fe056a564cbc9165907417c7ace215e889313648ef7188978de6967b
|
4
|
+
data.tar.gz: 641d48d8ea5501344b72db29beb2799acf7ffb8711c0b472b31b1cafa670365f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63b7b63b2e1d5a141ae795a628b838bfce9ee31a0d1dbcd8b8d693e776f15195a649f17d16c227f6a1f91dcc45026c499706de5fca14f9a2dc7fea2fa08f9eb4
|
7
|
+
data.tar.gz: 2fbf672737a8b1dc3ab33cd1edec06469ec0691c9c30ee23907e9811c1a263ac27293f659440050a5802bd3e1950891a75695e5b29ecc1a90a45515a4c0f5b5e
|
data/.github/workflows/test.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
name:
|
1
|
+
name: CI
|
2
2
|
|
3
3
|
on: [push, pull_request]
|
4
4
|
|
@@ -7,18 +7,15 @@ jobs:
|
|
7
7
|
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
8
8
|
strategy:
|
9
9
|
matrix:
|
10
|
-
ruby: [ 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 ]
|
11
11
|
os: [ ubuntu-latest, macos-latest ]
|
12
12
|
runs-on: ${{ matrix.os }}
|
13
13
|
steps:
|
14
|
-
- uses: actions/checkout@
|
14
|
+
- uses: actions/checkout@v3
|
15
15
|
- name: Set up Ruby
|
16
16
|
uses: ruby/setup-ruby@v1
|
17
17
|
with:
|
18
18
|
ruby-version: ${{ matrix.ruby }}
|
19
|
-
-
|
20
|
-
run: |
|
21
|
-
gem install bundler --no-document
|
22
|
-
bundle install
|
19
|
+
- run: bundle install --jobs 4 --retry 3
|
23
20
|
- name: Run test
|
24
21
|
run: rake test
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# URI
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
[![CI](https://github.com/ruby/uri/actions/workflows/test.yml/badge.svg)](https://github.com/ruby/uri/actions/workflows/test.yml)
|
4
|
+
|
5
|
+
URI is a module providing classes to handle Uniform Resource Identifiers [RFC2396](http://tools.ietf.org/html/rfc2396).
|
5
6
|
|
6
7
|
## Features
|
7
8
|
|
data/lib/uri/common.rb
CHANGED
@@ -13,9 +13,12 @@ require_relative "rfc2396_parser"
|
|
13
13
|
require_relative "rfc3986_parser"
|
14
14
|
|
15
15
|
module URI
|
16
|
+
include RFC2396_REGEXP
|
17
|
+
|
16
18
|
REGEXP = RFC2396_REGEXP
|
17
19
|
Parser = RFC2396_Parser
|
18
20
|
RFC3986_PARSER = RFC3986_Parser.new
|
21
|
+
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
|
19
22
|
|
20
23
|
# URI::Parser.new
|
21
24
|
DEFAULT_PARSER = Parser.new
|
@@ -27,6 +30,7 @@ module URI
|
|
27
30
|
DEFAULT_PARSER.regexp.each_pair do |sym, str|
|
28
31
|
const_set(sym, str)
|
29
32
|
end
|
33
|
+
Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
|
30
34
|
|
31
35
|
module Util # :nodoc:
|
32
36
|
def make_components_hash(klass, array_hash)
|
@@ -60,24 +64,42 @@ module URI
|
|
60
64
|
module_function :make_components_hash
|
61
65
|
end
|
62
66
|
|
63
|
-
|
67
|
+
module Schemes
|
68
|
+
end
|
69
|
+
private_constant :Schemes
|
70
|
+
|
71
|
+
#
|
72
|
+
# Register the given +klass+ to be instantiated when parsing URLs with the given +scheme+.
|
73
|
+
# Note that currently only schemes which after .upcase are valid constant names
|
74
|
+
# can be registered (no -/+/. allowed).
|
75
|
+
#
|
76
|
+
def self.register_scheme(scheme, klass)
|
77
|
+
Schemes.const_set(scheme.to_s.upcase, klass)
|
78
|
+
end
|
64
79
|
|
65
|
-
@@schemes = {}
|
66
80
|
# Returns a Hash of the defined schemes.
|
67
81
|
def self.scheme_list
|
68
|
-
|
82
|
+
Schemes.constants.map { |name|
|
83
|
+
[name.to_s.upcase, Schemes.const_get(name)]
|
84
|
+
}.to_h
|
69
85
|
end
|
70
86
|
|
87
|
+
INITIAL_SCHEMES = scheme_list
|
88
|
+
private_constant :INITIAL_SCHEMES
|
89
|
+
Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
|
90
|
+
|
71
91
|
#
|
72
92
|
# Construct a URI instance, using the scheme to detect the appropriate class
|
73
93
|
# from +URI.scheme_list+.
|
74
94
|
#
|
75
95
|
def self.for(scheme, *arguments, default: Generic)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
96
|
+
const_name = scheme.to_s.upcase
|
97
|
+
|
98
|
+
uri_class = INITIAL_SCHEMES[const_name]
|
99
|
+
uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
|
100
|
+
Schemes.const_get(const_name, false)
|
80
101
|
end
|
102
|
+
uri_class ||= default
|
81
103
|
|
82
104
|
return uri_class.new(scheme, *arguments)
|
83
105
|
end
|
@@ -278,6 +300,7 @@ module URI
|
|
278
300
|
256.times do |i|
|
279
301
|
TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
|
280
302
|
end
|
303
|
+
TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
|
281
304
|
TBLENCWWWCOMP_[' '] = '+'
|
282
305
|
TBLENCWWWCOMP_.freeze
|
283
306
|
TBLDECWWWCOMP_ = {} # :nodoc:
|
@@ -303,6 +326,33 @@ module URI
|
|
303
326
|
#
|
304
327
|
# See URI.decode_www_form_component, URI.encode_www_form.
|
305
328
|
def self.encode_www_form_component(str, enc=nil)
|
329
|
+
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
|
330
|
+
end
|
331
|
+
|
332
|
+
# Decodes given +str+ of URL-encoded form data.
|
333
|
+
#
|
334
|
+
# This decodes + to SP.
|
335
|
+
#
|
336
|
+
# See URI.encode_www_form_component, URI.decode_www_form.
|
337
|
+
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
338
|
+
_decode_uri_component(/\+|%\h\h/, str, enc)
|
339
|
+
end
|
340
|
+
|
341
|
+
# Encodes +str+ using URL encoding
|
342
|
+
#
|
343
|
+
# This encodes SP to %20 instead of +.
|
344
|
+
def self.encode_uri_component(str, enc=nil)
|
345
|
+
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
|
346
|
+
end
|
347
|
+
|
348
|
+
# Decodes given +str+ of URL-encoded data.
|
349
|
+
#
|
350
|
+
# This does not decode + to SP.
|
351
|
+
def self.decode_uri_component(str, enc=Encoding::UTF_8)
|
352
|
+
_decode_uri_component(/%\h\h/, str, enc)
|
353
|
+
end
|
354
|
+
|
355
|
+
def self._encode_uri_component(regexp, table, str, enc)
|
306
356
|
str = str.to_s.dup
|
307
357
|
if str.encoding != Encoding::ASCII_8BIT
|
308
358
|
if enc && enc != Encoding::ASCII_8BIT
|
@@ -311,19 +361,16 @@ module URI
|
|
311
361
|
end
|
312
362
|
str.force_encoding(Encoding::ASCII_8BIT)
|
313
363
|
end
|
314
|
-
str.gsub!(
|
364
|
+
str.gsub!(regexp, table)
|
315
365
|
str.force_encoding(Encoding::US_ASCII)
|
316
366
|
end
|
367
|
+
private_class_method :_encode_uri_component
|
317
368
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
#
|
322
|
-
# See URI.encode_www_form_component, URI.decode_www_form.
|
323
|
-
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
324
|
-
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
|
325
|
-
str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
|
369
|
+
def self._decode_uri_component(regexp, str, enc)
|
370
|
+
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
|
371
|
+
str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
|
326
372
|
end
|
373
|
+
private_class_method :_decode_uri_component
|
327
374
|
|
328
375
|
# Generates URL-encoded form data from given +enum+.
|
329
376
|
#
|
@@ -653,6 +700,7 @@ module URI
|
|
653
700
|
"utf-16"=>"utf-16le",
|
654
701
|
"utf-16le"=>"utf-16le",
|
655
702
|
} # :nodoc:
|
703
|
+
Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
|
656
704
|
|
657
705
|
# :nodoc:
|
658
706
|
# return encoding or nil
|
data/lib/uri/file.rb
CHANGED
@@ -33,6 +33,9 @@ module URI
|
|
33
33
|
# If an Array is used, the components must be passed in the
|
34
34
|
# order <code>[host, path]</code>.
|
35
35
|
#
|
36
|
+
# A path from e.g. the File class should be escaped before
|
37
|
+
# being passed.
|
38
|
+
#
|
36
39
|
# Examples:
|
37
40
|
#
|
38
41
|
# require 'uri'
|
@@ -44,6 +47,9 @@ module URI
|
|
44
47
|
# :path => '/ruby/src'})
|
45
48
|
# uri2.to_s # => "file://host.example.com/ruby/src"
|
46
49
|
#
|
50
|
+
# uri3 = URI::File.build({:path => URI::escape('/path/my file.txt')})
|
51
|
+
# uri3.to_s # => "file:///path/my%20file.txt"
|
52
|
+
#
|
47
53
|
def self.build(args)
|
48
54
|
tmp = Util::make_components_hash(self, args)
|
49
55
|
super(tmp)
|
@@ -90,5 +96,5 @@ module URI
|
|
90
96
|
end
|
91
97
|
end
|
92
98
|
|
93
|
-
|
99
|
+
register_scheme 'FILE', File
|
94
100
|
end
|
data/lib/uri/ftp.rb
CHANGED
data/lib/uri/generic.rb
CHANGED
@@ -564,16 +564,26 @@ module URI
|
|
564
564
|
end
|
565
565
|
end
|
566
566
|
|
567
|
-
# Returns the user component.
|
567
|
+
# Returns the user component (without URI decoding).
|
568
568
|
def user
|
569
569
|
@user
|
570
570
|
end
|
571
571
|
|
572
|
-
# Returns the password component.
|
572
|
+
# Returns the password component (without URI decoding).
|
573
573
|
def password
|
574
574
|
@password
|
575
575
|
end
|
576
576
|
|
577
|
+
# Returns the user component after URI decoding.
|
578
|
+
def decoded_user
|
579
|
+
URI.decode_uri_component(@user) if @user
|
580
|
+
end
|
581
|
+
|
582
|
+
# Returns the password component after URI decoding.
|
583
|
+
def decoded_password
|
584
|
+
URI.decode_uri_component(@password) if @password
|
585
|
+
end
|
586
|
+
|
577
587
|
#
|
578
588
|
# Checks the host +v+ component for RFC2396 compliance
|
579
589
|
# and against the URI::Parser Regexp for :HOST.
|
@@ -643,7 +653,7 @@ module URI
|
|
643
653
|
#
|
644
654
|
def hostname
|
645
655
|
v = self.host
|
646
|
-
|
656
|
+
v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v
|
647
657
|
end
|
648
658
|
|
649
659
|
# Sets the host part of the URI as the argument with brackets for IPv6 addresses.
|
@@ -659,7 +669,7 @@ module URI
|
|
659
669
|
# it is wrapped with brackets.
|
660
670
|
#
|
661
671
|
def hostname=(v)
|
662
|
-
v = "[#{v}]" if
|
672
|
+
v = "[#{v}]" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')
|
663
673
|
self.host = v
|
664
674
|
end
|
665
675
|
|
@@ -1514,9 +1524,19 @@ module URI
|
|
1514
1524
|
proxy_uri = env["CGI_#{name.upcase}"]
|
1515
1525
|
end
|
1516
1526
|
elsif name == 'http_proxy'
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1527
|
+
if RUBY_ENGINE == 'jruby' && p_addr = ENV_JAVA['http.proxyHost']
|
1528
|
+
p_port = ENV_JAVA['http.proxyPort']
|
1529
|
+
if p_user = ENV_JAVA['http.proxyUser']
|
1530
|
+
p_pass = ENV_JAVA['http.proxyPass']
|
1531
|
+
proxy_uri = "http://#{p_user}:#{p_pass}@#{p_addr}:#{p_port}"
|
1532
|
+
else
|
1533
|
+
proxy_uri = "http://#{p_addr}:#{p_port}"
|
1534
|
+
end
|
1535
|
+
else
|
1536
|
+
unless proxy_uri = env[name]
|
1537
|
+
if proxy_uri = env[name.upcase]
|
1538
|
+
warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
|
1539
|
+
end
|
1520
1540
|
end
|
1521
1541
|
end
|
1522
1542
|
else
|
data/lib/uri/http.rb
CHANGED
@@ -80,8 +80,46 @@ module URI
|
|
80
80
|
url = @query ? "#@path?#@query" : @path.dup
|
81
81
|
url.start_with?(?/.freeze) ? url : ?/ + url
|
82
82
|
end
|
83
|
-
end
|
84
83
|
|
85
|
-
|
84
|
+
#
|
85
|
+
# == Description
|
86
|
+
#
|
87
|
+
# Returns the authority for an HTTP uri, as defined in
|
88
|
+
# https://datatracker.ietf.org/doc/html/rfc3986/#section-3.2.
|
89
|
+
#
|
90
|
+
#
|
91
|
+
# Example:
|
92
|
+
#
|
93
|
+
# URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').authority #=> "www.example.com"
|
94
|
+
# URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').authority #=> "www.example.com:8000"
|
95
|
+
# URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').authority #=> "www.example.com"
|
96
|
+
#
|
97
|
+
def authority
|
98
|
+
if port == default_port
|
99
|
+
host
|
100
|
+
else
|
101
|
+
"#{host}:#{port}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# == Description
|
107
|
+
#
|
108
|
+
# Returns the origin for an HTTP uri, as defined in
|
109
|
+
# https://datatracker.ietf.org/doc/html/rfc6454.
|
110
|
+
#
|
111
|
+
#
|
112
|
+
# Example:
|
113
|
+
#
|
114
|
+
# URI::HTTP.build(host: 'www.example.com', path: '/foo/bar').origin #=> "http://www.example.com"
|
115
|
+
# URI::HTTP.build(host: 'www.example.com', port: 8000, path: '/foo/bar').origin #=> "http://www.example.com:8000"
|
116
|
+
# URI::HTTP.build(host: 'www.example.com', port: 80, path: '/foo/bar').origin #=> "http://www.example.com"
|
117
|
+
# URI::HTTPS.build(host: 'www.example.com', path: '/foo/bar').origin #=> "https://www.example.com"
|
118
|
+
#
|
119
|
+
def origin
|
120
|
+
"#{scheme}://#{authority}"
|
121
|
+
end
|
122
|
+
end
|
86
123
|
|
124
|
+
register_scheme 'HTTP', HTTP
|
87
125
|
end
|
data/lib/uri/https.rb
CHANGED
data/lib/uri/ldap.rb
CHANGED
data/lib/uri/ldaps.rb
CHANGED
data/lib/uri/mailto.rb
CHANGED
@@ -15,7 +15,7 @@ module URI
|
|
15
15
|
# RFC6068, the mailto URL scheme.
|
16
16
|
#
|
17
17
|
class MailTo < Generic
|
18
|
-
include
|
18
|
+
include RFC2396_REGEXP
|
19
19
|
|
20
20
|
# A Default port of nil for URI::MailTo.
|
21
21
|
DEFAULT_PORT = nil
|
@@ -289,5 +289,5 @@ module URI
|
|
289
289
|
alias to_rfc822text to_mailtext
|
290
290
|
end
|
291
291
|
|
292
|
-
|
292
|
+
register_scheme 'MAILTO', MailTo
|
293
293
|
end
|
data/lib/uri/rfc2396_parser.rb
CHANGED
@@ -116,7 +116,7 @@ module URI
|
|
116
116
|
# See also URI::Parser.initialize_regexp.
|
117
117
|
attr_reader :regexp
|
118
118
|
|
119
|
-
# Returns a split URI against regexp[:ABS_URI]
|
119
|
+
# Returns a split URI against +regexp[:ABS_URI]+.
|
120
120
|
def split(uri)
|
121
121
|
case uri
|
122
122
|
when ''
|
@@ -257,8 +257,8 @@ module URI
|
|
257
257
|
end
|
258
258
|
end
|
259
259
|
|
260
|
-
# Returns Regexp that is default self.regexp[:ABS_URI_REF]
|
261
|
-
# unless +schemes+ is provided. Then it is a Regexp.union with self.pattern[:X_ABS_URI]
|
260
|
+
# Returns Regexp that is default +self.regexp[:ABS_URI_REF]+,
|
261
|
+
# unless +schemes+ is provided. Then it is a Regexp.union with +self.pattern[:X_ABS_URI]+.
|
262
262
|
def make_regexp(schemes = nil)
|
263
263
|
unless schemes
|
264
264
|
@regexp[:ABS_URI_REF]
|
@@ -277,7 +277,7 @@ module URI
|
|
277
277
|
# +str+::
|
278
278
|
# String to make safe
|
279
279
|
# +unsafe+::
|
280
|
-
# Regexp to apply. Defaults to self.regexp[:UNSAFE]
|
280
|
+
# Regexp to apply. Defaults to +self.regexp[:UNSAFE]+
|
281
281
|
#
|
282
282
|
# == Description
|
283
283
|
#
|
@@ -309,7 +309,7 @@ module URI
|
|
309
309
|
# +str+::
|
310
310
|
# String to remove escapes from
|
311
311
|
# +escaped+::
|
312
|
-
# Regexp to apply. Defaults to self.regexp[:ESCAPED]
|
312
|
+
# Regexp to apply. Defaults to +self.regexp[:ESCAPED]+
|
313
313
|
#
|
314
314
|
# == Description
|
315
315
|
#
|
@@ -322,8 +322,14 @@ module URI
|
|
322
322
|
end
|
323
323
|
|
324
324
|
@@to_s = Kernel.instance_method(:to_s)
|
325
|
-
|
326
|
-
|
325
|
+
if @@to_s.respond_to?(:bind_call)
|
326
|
+
def inspect
|
327
|
+
@@to_s.bind_call(self)
|
328
|
+
end
|
329
|
+
else
|
330
|
+
def inspect
|
331
|
+
@@to_s.bind(self).call
|
332
|
+
end
|
327
333
|
end
|
328
334
|
|
329
335
|
private
|
@@ -491,8 +497,8 @@ module URI
|
|
491
497
|
ret = {}
|
492
498
|
|
493
499
|
# for URI::split
|
494
|
-
ret[:ABS_URI] = Regexp.new('\A\s
|
495
|
-
ret[:REL_URI] = Regexp.new('\A\s
|
500
|
+
ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
|
501
|
+
ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
|
496
502
|
|
497
503
|
# for URI::extract
|
498
504
|
ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
|
data/lib/uri/rfc3986_parser.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
module URI
|
3
3
|
class RFC3986_Parser # :nodoc:
|
4
4
|
# URI defined in RFC3986
|
5
|
-
|
6
|
-
RFC3986_URI = /\A(?<URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*+):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*+)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h++\.[!$&-.0-;=A-Z_a-z~]++))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])++))?(?::(?<port>\d*+))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*+))*+)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])++)(?:\/\g<segment>)*+)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*+)|(?<path-empty>))(?:\?(?<query>[^#]*+))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*+))?)\z/
|
5
|
+
RFC3986_URI = /\A(?<URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*+):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*+)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h++\.[!$&-.0-;=A-Z_a-z~]++))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*+))(?::(?<port>\d*+))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*+))*+)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])++)(?:\/\g<segment>)*+)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*+)|(?<path-empty>))(?:\?(?<query>[^#]*+))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*+))?)\z/
|
7
6
|
RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*+)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h++\.[!$&-.0-;=A-Z_a-z~]++))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])++))?(?::(?<port>\d*+))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*+))*+)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])++)(?:\/\g<segment>)*+)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])++)(?:\/\g<segment>)*+)|(?<path-empty>))(?:\?(?<query>[^#]*+))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*+))?)\z/
|
8
7
|
attr_reader :regexp
|
9
8
|
|
@@ -79,8 +78,14 @@ module URI
|
|
79
78
|
end
|
80
79
|
|
81
80
|
@@to_s = Kernel.instance_method(:to_s)
|
82
|
-
|
83
|
-
|
81
|
+
if @@to_s.respond_to?(:bind_call)
|
82
|
+
def inspect
|
83
|
+
@@to_s.bind_call(self)
|
84
|
+
end
|
85
|
+
else
|
86
|
+
def inspect
|
87
|
+
@@to_s.bind(self).call
|
88
|
+
end
|
84
89
|
end
|
85
90
|
|
86
91
|
private
|
@@ -95,7 +100,7 @@ module URI
|
|
95
100
|
QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
|
96
101
|
FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
|
97
102
|
OPAQUE: /\A(?:[^\/].*)?\z/,
|
98
|
-
PORT: /\A[\x09\x0a\x0c\x0d ]
|
103
|
+
PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
|
99
104
|
}
|
100
105
|
end
|
101
106
|
|
data/lib/uri/version.rb
CHANGED
data/lib/uri/ws.rb
CHANGED
data/lib/uri/wss.rb
CHANGED
data/lib/uri.rb
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
# class RSYNC < Generic
|
31
31
|
# DEFAULT_PORT = 873
|
32
32
|
# end
|
33
|
-
#
|
33
|
+
# register_scheme 'RSYNC', RSYNC
|
34
34
|
# end
|
35
35
|
# #=> URI::RSYNC
|
36
36
|
#
|
@@ -70,7 +70,6 @@
|
|
70
70
|
# - URI::REGEXP - (in uri/common.rb)
|
71
71
|
# - URI::REGEXP::PATTERN - (in uri/common.rb)
|
72
72
|
# - URI::Util - (in uri/common.rb)
|
73
|
-
# - URI::Escape - (in uri/common.rb)
|
74
73
|
# - URI::Error - (in uri/common.rb)
|
75
74
|
# - URI::InvalidURIError - (in uri/common.rb)
|
76
75
|
# - URI::InvalidComponentError - (in uri/common.rb)
|
@@ -101,3 +100,5 @@ require_relative 'uri/https'
|
|
101
100
|
require_relative 'uri/ldap'
|
102
101
|
require_relative 'uri/ldaps'
|
103
102
|
require_relative 'uri/mailto'
|
103
|
+
require_relative 'uri/ws'
|
104
|
+
require_relative 'uri/wss'
|
data/uri.gemspec
CHANGED
@@ -15,6 +15,8 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.homepage = "https://github.com/ruby/uri"
|
16
16
|
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
17
17
|
|
18
|
+
spec.required_ruby_version = '>= 2.4'
|
19
|
+
|
18
20
|
spec.metadata["homepage_uri"] = spec.homepage
|
19
21
|
spec.metadata["source_code_uri"] = spec.homepage
|
20
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Yamada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: URI is a module providing classes to handle Uniform Resource Identifiers
|
14
14
|
email:
|
@@ -17,6 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/dependabot.yml"
|
20
21
|
- ".github/workflows/test.yml"
|
21
22
|
- ".gitignore"
|
22
23
|
- Gemfile
|
@@ -56,14 +57,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
57
|
requirements:
|
57
58
|
- - ">="
|
58
59
|
- !ruby/object:Gem::Version
|
59
|
-
version: '
|
60
|
+
version: '2.4'
|
60
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
62
|
requirements:
|
62
63
|
- - ">="
|
63
64
|
- !ruby/object:Gem::Version
|
64
65
|
version: '0'
|
65
66
|
requirements: []
|
66
|
-
rubygems_version: 3.
|
67
|
+
rubygems_version: 3.3.26
|
67
68
|
signing_key:
|
68
69
|
specification_version: 4
|
69
70
|
summary: URI is a module providing classes to handle Uniform Resource Identifiers
|