uri 0.10.3 → 0.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 402696d2448e1f1d9d14d6307ee4a61f4e5370760088c03baefcfc904bae529c
4
- data.tar.gz: 9d073ce507b29a3fe2eea321a53fd614da025f964442a8aa47f73f165996765c
3
+ metadata.gz: 522757d2dcaf03c71cf264ebe70ebc52977e41f0ebdfd571736e75bd68bf8b06
4
+ data.tar.gz: 2b95b950a4c1b64ba908f5bc2faf33994ceabf74a7b00b90df8d1535b77487a1
5
5
  SHA512:
6
- metadata.gz: 3ef56ee95d5cd944c344db8c55e3023898cefc82b3382dc9fc5bf0a9f7bb959901c492f7829cc3ebed02f35ec978a680a3608839fa5fc4072708220fa4b818c9
7
- data.tar.gz: 6b2d67e0b317f800a1db9d2b0e64bc757abb7f53d5e006e7e440f1f04b562afbd5c2184ec2458ea5c76983866024d5fc56189e650f1b2187b7ac7907d4d892e4
6
+ metadata.gz: 28e9ddf4e9c71eb4e92ceef3cdcf3119b11f722197f39157fa61df13de44d967a4694ee87e6ad0a4d21e0047f12818473914000ebc5d96810dec55544e157b6b
7
+ data.tar.gz: cb098d2164e1dbf3e310ff11fcd9428a1beec85dbcca9b116b2dba7ba0408a82af4a71b5240dfa0a6498bf747360accd7d03d4a89dcb7c2842139430301e4839
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
@@ -1,4 +1,4 @@
1
- name: ubuntu
1
+ name: CI
2
2
 
3
3
  on: [push, pull_request]
4
4
 
@@ -7,18 +7,20 @@ 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
+ exclude:
13
+ - ruby: 2.4
14
+ os: macos-latest
15
+ - ruby: 2.5
16
+ os: macos-latest
12
17
  runs-on: ${{ matrix.os }}
13
18
  steps:
14
- - uses: actions/checkout@master
19
+ - uses: actions/checkout@v3
15
20
  - name: Set up Ruby
16
21
  uses: ruby/setup-ruby@v1
17
22
  with:
18
23
  ruby-version: ${{ matrix.ruby }}
19
- - name: Install dependencies
20
- run: |
21
- gem install bundler --no-document
22
- bundle install
24
+ - run: bundle install --jobs 4 --retry 3
23
25
  - name: Run test
24
26
  run: rake test
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # URI
2
2
 
3
- URI is a module providing classes to handle Uniform Resource Identifiers
4
- (RFC2396[http://tools.ietf.org/html/rfc2396]).
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,14 @@ 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)
22
+ RFC2396_PARSER = RFC2396_Parser.new
23
+ Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
19
24
 
20
25
  # URI::Parser.new
21
26
  DEFAULT_PARSER = Parser.new
@@ -27,6 +32,7 @@ module URI
27
32
  DEFAULT_PARSER.regexp.each_pair do |sym, str|
28
33
  const_set(sym, str)
29
34
  end
35
+ Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
30
36
 
31
37
  module Util # :nodoc:
32
38
  def make_components_hash(klass, array_hash)
@@ -60,24 +66,42 @@ module URI
60
66
  module_function :make_components_hash
61
67
  end
62
68
 
63
- include REGEXP
69
+ module Schemes
70
+ end
71
+ private_constant :Schemes
72
+
73
+ #
74
+ # Register the given +klass+ to be instantiated when parsing URLs with the given +scheme+.
75
+ # Note that currently only schemes which after .upcase are valid constant names
76
+ # can be registered (no -/+/. allowed).
77
+ #
78
+ def self.register_scheme(scheme, klass)
79
+ Schemes.const_set(scheme.to_s.upcase, klass)
80
+ end
64
81
 
65
- @@schemes = {}
66
82
  # Returns a Hash of the defined schemes.
67
83
  def self.scheme_list
68
- @@schemes
84
+ Schemes.constants.map { |name|
85
+ [name.to_s.upcase, Schemes.const_get(name)]
86
+ }.to_h
69
87
  end
70
88
 
89
+ INITIAL_SCHEMES = scheme_list
90
+ private_constant :INITIAL_SCHEMES
91
+ Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
92
+
71
93
  #
72
94
  # Construct a URI instance, using the scheme to detect the appropriate class
73
95
  # from +URI.scheme_list+.
74
96
  #
75
97
  def self.for(scheme, *arguments, default: Generic)
76
- if scheme
77
- uri_class = @@schemes[scheme.upcase] || default
78
- else
79
- uri_class = default
98
+ const_name = scheme.to_s.upcase
99
+
100
+ uri_class = INITIAL_SCHEMES[const_name]
101
+ uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
102
+ Schemes.const_get(const_name, false)
80
103
  end
104
+ uri_class ||= default
81
105
 
82
106
  return uri_class.new(scheme, *arguments)
83
107
  end
@@ -278,6 +302,7 @@ module URI
278
302
  256.times do |i|
279
303
  TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
280
304
  end
305
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
281
306
  TBLENCWWWCOMP_[' '] = '+'
282
307
  TBLENCWWWCOMP_.freeze
283
308
  TBLDECWWWCOMP_ = {} # :nodoc:
@@ -303,6 +328,33 @@ module URI
303
328
  #
304
329
  # See URI.decode_www_form_component, URI.encode_www_form.
305
330
  def self.encode_www_form_component(str, enc=nil)
331
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
332
+ end
333
+
334
+ # Decodes given +str+ of URL-encoded form data.
335
+ #
336
+ # This decodes + to SP.
337
+ #
338
+ # See URI.encode_www_form_component, URI.decode_www_form.
339
+ def self.decode_www_form_component(str, enc=Encoding::UTF_8)
340
+ _decode_uri_component(/\+|%\h\h/, str, enc)
341
+ end
342
+
343
+ # Encodes +str+ using URL encoding
344
+ #
345
+ # This encodes SP to %20 instead of +.
346
+ def self.encode_uri_component(str, enc=nil)
347
+ _encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
348
+ end
349
+
350
+ # Decodes given +str+ of URL-encoded data.
351
+ #
352
+ # This does not decode + to SP.
353
+ def self.decode_uri_component(str, enc=Encoding::UTF_8)
354
+ _decode_uri_component(/%\h\h/, str, enc)
355
+ end
356
+
357
+ def self._encode_uri_component(regexp, table, str, enc)
306
358
  str = str.to_s.dup
307
359
  if str.encoding != Encoding::ASCII_8BIT
308
360
  if enc && enc != Encoding::ASCII_8BIT
@@ -311,19 +363,16 @@ module URI
311
363
  end
312
364
  str.force_encoding(Encoding::ASCII_8BIT)
313
365
  end
314
- str.gsub!(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_)
366
+ str.gsub!(regexp, table)
315
367
  str.force_encoding(Encoding::US_ASCII)
316
368
  end
369
+ private_class_method :_encode_uri_component
317
370
 
318
- # Decodes given +str+ of URL-encoded form data.
319
- #
320
- # This decodes + to SP.
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)
371
+ def self._decode_uri_component(regexp, str, enc)
372
+ raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
373
+ str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
326
374
  end
375
+ private_class_method :_decode_uri_component
327
376
 
328
377
  # Generates URL-encoded form data from given +enum+.
329
378
  #
@@ -653,6 +702,7 @@ module URI
653
702
  "utf-16"=>"utf-16le",
654
703
  "utf-16le"=>"utf-16le",
655
704
  } # :nodoc:
705
+ Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
656
706
 
657
707
  # :nodoc:
658
708
  # 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
- @@schemes['FILE'] = File
99
+ register_scheme 'FILE', File
94
100
  end
data/lib/uri/ftp.rb CHANGED
@@ -262,5 +262,6 @@ module URI
262
262
  return str
263
263
  end
264
264
  end
265
- @@schemes['FTP'] = FTP
265
+
266
+ register_scheme 'FTP', FTP
266
267
  end
data/lib/uri/generic.rb CHANGED
@@ -186,18 +186,18 @@ module URI
186
186
 
187
187
  if arg_check
188
188
  self.scheme = scheme
189
- self.userinfo = userinfo
190
189
  self.hostname = host
191
190
  self.port = port
191
+ self.userinfo = userinfo
192
192
  self.path = path
193
193
  self.query = query
194
194
  self.opaque = opaque
195
195
  self.fragment = fragment
196
196
  else
197
197
  self.set_scheme(scheme)
198
- self.set_userinfo(userinfo)
199
198
  self.set_host(host)
200
199
  self.set_port(port)
200
+ self.set_userinfo(userinfo)
201
201
  self.set_path(path)
202
202
  self.query = query
203
203
  self.set_opaque(opaque)
@@ -511,7 +511,7 @@ module URI
511
511
  user, password = split_userinfo(user)
512
512
  end
513
513
  @user = user
514
- @password = password if password
514
+ @password = password
515
515
 
516
516
  [@user, @password]
517
517
  end
@@ -522,7 +522,7 @@ module URI
522
522
  # See also URI::Generic.user=.
523
523
  #
524
524
  def set_user(v)
525
- set_userinfo(v, @password)
525
+ set_userinfo(v, nil)
526
526
  v
527
527
  end
528
528
  protected :set_user
@@ -564,16 +564,32 @@ 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 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
+
583
+ # Returns the user component after URI decoding.
584
+ def decoded_user
585
+ URI.decode_uri_component(@user) if @user
586
+ end
587
+
588
+ # Returns the password component after URI decoding.
589
+ def decoded_password
590
+ URI.decode_uri_component(@password) if @password
591
+ end
592
+
577
593
  #
578
594
  # Checks the host +v+ component for RFC2396 compliance
579
595
  # and against the URI::Parser Regexp for :HOST.
@@ -605,6 +621,13 @@ module URI
605
621
  end
606
622
  protected :set_host
607
623
 
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
+
608
631
  #
609
632
  # == Args
610
633
  #
@@ -629,6 +652,7 @@ module URI
629
652
  def host=(v)
630
653
  check_host(v)
631
654
  set_host(v)
655
+ set_userinfo(nil)
632
656
  v
633
657
  end
634
658
 
@@ -643,7 +667,7 @@ module URI
643
667
  #
644
668
  def hostname
645
669
  v = self.host
646
- /\A\[(.*)\]\z/ =~ v ? $1 : v
670
+ v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v
647
671
  end
648
672
 
649
673
  # Sets the host part of the URI as the argument with brackets for IPv6 addresses.
@@ -659,7 +683,7 @@ module URI
659
683
  # it is wrapped with brackets.
660
684
  #
661
685
  def hostname=(v)
662
- v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v
686
+ v = "[#{v}]" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')
663
687
  self.host = v
664
688
  end
665
689
 
@@ -719,6 +743,7 @@ module URI
719
743
  def port=(v)
720
744
  check_port(v)
721
745
  set_port(v)
746
+ set_userinfo(nil)
722
747
  port
723
748
  end
724
749
 
@@ -1111,7 +1136,7 @@ module URI
1111
1136
 
1112
1137
  base = self.dup
1113
1138
 
1114
- authority = rel.userinfo || rel.host || rel.port
1139
+ authority = rel.authority
1115
1140
 
1116
1141
  # RFC2396, Section 5.2, 2)
1117
1142
  if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
@@ -1123,17 +1148,14 @@ module URI
1123
1148
  base.fragment=(nil)
1124
1149
 
1125
1150
  # 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
1151
+ if authority
1152
+ base.set_authority(*authority)
1153
+ base.set_path(rel.path)
1154
+ elsif base.path && rel.path
1155
+ base.set_path(merge_path(base.path, rel.path))
1131
1156
  end
1132
1157
 
1133
1158
  # 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
1137
1159
  base.query = rel.query if rel.query
1138
1160
  base.fragment=(rel.fragment) if rel.fragment
1139
1161
 
@@ -1514,9 +1536,19 @@ module URI
1514
1536
  proxy_uri = env["CGI_#{name.upcase}"]
1515
1537
  end
1516
1538
  elsif name == 'http_proxy'
1517
- unless proxy_uri = env[name]
1518
- if proxy_uri = env[name.upcase]
1519
- warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
1539
+ if RUBY_ENGINE == 'jruby' && p_addr = ENV_JAVA['http.proxyHost']
1540
+ p_port = ENV_JAVA['http.proxyPort']
1541
+ if p_user = ENV_JAVA['http.proxyUser']
1542
+ p_pass = ENV_JAVA['http.proxyPass']
1543
+ proxy_uri = "http://#{p_user}:#{p_pass}@#{p_addr}:#{p_port}"
1544
+ else
1545
+ proxy_uri = "http://#{p_addr}:#{p_port}"
1546
+ end
1547
+ else
1548
+ unless proxy_uri = env[name]
1549
+ if proxy_uri = env[name.upcase]
1550
+ warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
1551
+ end
1520
1552
  end
1521
1553
  end
1522
1554
  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
- @@schemes['HTTP'] = HTTP
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
@@ -18,5 +18,6 @@ module URI
18
18
  # A Default port of 443 for URI::HTTPS
19
19
  DEFAULT_PORT = 443
20
20
  end
21
- @@schemes['HTTPS'] = HTTPS
21
+
22
+ register_scheme 'HTTPS', HTTPS
22
23
  end
data/lib/uri/ldap.rb CHANGED
@@ -257,5 +257,5 @@ module URI
257
257
  end
258
258
  end
259
259
 
260
- @@schemes['LDAP'] = LDAP
260
+ register_scheme 'LDAP', LDAP
261
261
  end
data/lib/uri/ldaps.rb CHANGED
@@ -17,5 +17,6 @@ module URI
17
17
  # A Default port of 636 for URI::LDAPS
18
18
  DEFAULT_PORT = 636
19
19
  end
20
- @@schemes['LDAPS'] = LDAPS
20
+
21
+ register_scheme 'LDAPS', LDAPS
21
22
  end
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 REGEXP
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
- @@schemes['MAILTO'] = MailTo
292
+ register_scheme 'MAILTO', MailTo
293
293
  end
@@ -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
- def inspect
326
- @@to_s.bind_call(self)
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
@@ -2,8 +2,7 @@
2
2
  module URI
3
3
  class RFC3986_Parser # :nodoc:
4
4
  # URI defined in RFC3986
5
- # this regexp is modified not to host is not empty string
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
- def inspect
83
- @@to_s.bind_call(self)
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
data/lib/uri/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module URI
2
2
  # :stopdoc:
3
- VERSION_CODE = '001003'.freeze
3
+ VERSION_CODE = '001205'.freeze
4
4
  VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
5
5
  # :startdoc:
6
6
  end
data/lib/uri/ws.rb CHANGED
@@ -79,6 +79,5 @@ module URI
79
79
  end
80
80
  end
81
81
 
82
- @@schemes['WS'] = WS
83
-
82
+ register_scheme 'WS', WS
84
83
  end
data/lib/uri/wss.rb CHANGED
@@ -18,5 +18,6 @@ module URI
18
18
  # A Default port of 443 for URI::WSS
19
19
  DEFAULT_PORT = 443
20
20
  end
21
- @@schemes['WSS'] = WSS
21
+
22
+ register_scheme 'WSS', WSS
22
23
  end
data/lib/uri.rb CHANGED
@@ -30,7 +30,7 @@
30
30
  # class RSYNC < Generic
31
31
  # DEFAULT_PORT = 873
32
32
  # end
33
- # @@schemes['RSYNC'] = RSYNC
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,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.12.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Yamada
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-06-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: URI is a module providing classes to handle Uniform Resource Identifiers
14
13
  email:
@@ -17,6 +16,7 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
19
+ - ".github/dependabot.yml"
20
20
  - ".github/workflows/test.yml"
21
21
  - ".gitignore"
22
22
  - Gemfile
@@ -48,7 +48,6 @@ licenses:
48
48
  metadata:
49
49
  homepage_uri: https://github.com/ruby/uri
50
50
  source_code_uri: https://github.com/ruby/uri
51
- post_install_message:
52
51
  rdoc_options: []
53
52
  require_paths:
54
53
  - lib
@@ -56,15 +55,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
55
  requirements:
57
56
  - - ">="
58
57
  - !ruby/object:Gem::Version
59
- version: '0'
58
+ version: '2.4'
60
59
  required_rubygems_version: !ruby/object:Gem::Requirement
61
60
  requirements:
62
61
  - - ">="
63
62
  - !ruby/object:Gem::Version
64
63
  version: '0'
65
64
  requirements: []
66
- rubygems_version: 3.3.26
67
- signing_key:
65
+ rubygems_version: 3.8.0.dev
68
66
  specification_version: 4
69
67
  summary: URI is a module providing classes to handle Uniform Resource Identifiers
70
68
  test_files: []