uri 0.11.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: c29481905b99ec405086769e5fce6c32539064d0a2917b23d4dddd8419e4db0d
4
- data.tar.gz: 5bbfeac4e030df131451c4847132e360d48f76f9d1e4344f8eba92dd6a07d8d7
3
+ metadata.gz: 522757d2dcaf03c71cf264ebe70ebc52977e41f0ebdfd571736e75bd68bf8b06
4
+ data.tar.gz: 2b95b950a4c1b64ba908f5bc2faf33994ceabf74a7b00b90df8d1535b77487a1
5
5
  SHA512:
6
- metadata.gz: da33d741be44959eeb82c761c53a6d4a9483554d08be0ef0939ee146d991aa1117d0d89d3c917ee1ed2b44d39c03cc465de71cb556d24861ffb907053b013034
7
- data.tar.gz: 347fc502d30a10cb3f24dc06945780c625dde86737c48e904cff913726385c5a54e5ae0ba8e8036e3c3f1457f8003eea8b7fffe44dd6f3f4481d0ed563fd3289
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'
data/lib/uri/common.rb CHANGED
@@ -13,10 +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
19
21
  Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
22
+ RFC2396_PARSER = RFC2396_Parser.new
23
+ Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
20
24
 
21
25
  # URI::Parser.new
22
26
  DEFAULT_PARSER = Parser.new
@@ -62,14 +66,17 @@ module URI
62
66
  module_function :make_components_hash
63
67
  end
64
68
 
65
- include REGEXP
66
-
67
69
  module Schemes
68
70
  end
69
71
  private_constant :Schemes
70
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
+ #
71
78
  def self.register_scheme(scheme, klass)
72
- Schemes.const_set(scheme, klass)
79
+ Schemes.const_set(scheme.to_s.upcase, klass)
73
80
  end
74
81
 
75
82
  # Returns a Hash of the defined schemes.
@@ -295,6 +302,7 @@ module URI
295
302
  256.times do |i|
296
303
  TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
297
304
  end
305
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
298
306
  TBLENCWWWCOMP_[' '] = '+'
299
307
  TBLENCWWWCOMP_.freeze
300
308
  TBLDECWWWCOMP_ = {} # :nodoc:
@@ -320,6 +328,33 @@ module URI
320
328
  #
321
329
  # See URI.decode_www_form_component, URI.encode_www_form.
322
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)
323
358
  str = str.to_s.dup
324
359
  if str.encoding != Encoding::ASCII_8BIT
325
360
  if enc && enc != Encoding::ASCII_8BIT
@@ -328,19 +363,16 @@ module URI
328
363
  end
329
364
  str.force_encoding(Encoding::ASCII_8BIT)
330
365
  end
331
- str.gsub!(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_)
366
+ str.gsub!(regexp, table)
332
367
  str.force_encoding(Encoding::US_ASCII)
333
368
  end
369
+ private_class_method :_encode_uri_component
334
370
 
335
- # Decodes given +str+ of URL-encoded form data.
336
- #
337
- # This decodes + to SP.
338
- #
339
- # See URI.encode_www_form_component, URI.decode_www_form.
340
- def self.decode_www_form_component(str, enc=Encoding::UTF_8)
371
+ def self._decode_uri_component(regexp, str, enc)
341
372
  raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
342
- str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
373
+ str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
343
374
  end
375
+ private_class_method :_decode_uri_component
344
376
 
345
377
  # Generates URL-encoded form data from given +enum+.
346
378
  #
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)
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
 
@@ -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
@@ -1124,9 +1149,7 @@ module URI
1124
1149
 
1125
1150
  # RFC2396, Section 5.2, 4)
1126
1151
  if authority
1127
- base.set_userinfo(rel.userinfo)
1128
- base.set_host(rel.host)
1129
- base.set_port(rel.port || base.default_port)
1152
+ base.set_authority(*authority)
1130
1153
  base.set_path(rel.path)
1131
1154
  elsif base.path && rel.path
1132
1155
  base.set_path(merge_path(base.path, rel.path))
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
@@ -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
 
data/lib/uri/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module URI
2
2
  # :stopdoc:
3
- VERSION_CODE = '001103'.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.rb CHANGED
@@ -101,3 +101,4 @@ require_relative 'uri/ldap'
101
101
  require_relative 'uri/ldaps'
102
102
  require_relative 'uri/mailto'
103
103
  require_relative 'uri/ws'
104
+ require_relative 'uri/wss'
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.11.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: 2025-02-26 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
@@ -63,8 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
62
  - !ruby/object:Gem::Version
64
63
  version: '0'
65
64
  requirements: []
66
- rubygems_version: 3.4.19
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: []