uri 0.11.3 → 0.12.4

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.

Potentially problematic release.


This version of uri might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c29481905b99ec405086769e5fce6c32539064d0a2917b23d4dddd8419e4db0d
4
- data.tar.gz: 5bbfeac4e030df131451c4847132e360d48f76f9d1e4344f8eba92dd6a07d8d7
3
+ metadata.gz: 5c43a663680279fb560cd1743d6ddd5c8d856b938381b16c525ca467ca4f53d8
4
+ data.tar.gz: 41bf92949944caad1719afe0b2067d5889104430e938e84e183cfd81e2a048c7
5
5
  SHA512:
6
- metadata.gz: da33d741be44959eeb82c761c53a6d4a9483554d08be0ef0939ee146d991aa1117d0d89d3c917ee1ed2b44d39c03cc465de71cb556d24861ffb907053b013034
7
- data.tar.gz: 347fc502d30a10cb3f24dc06945780c625dde86737c48e904cff913726385c5a54e5ae0ba8e8036e3c3f1457f8003eea8b7fffe44dd6f3f4481d0ed563fd3289
6
+ metadata.gz: '08c726bbfda93cdeeb7236715ca3c81dfcdaa54dc14084ddd1b61802f819311461973f79845ce410d2e2024ee06ea3921afc5fad3d4323afd9006d5ee2311a06'
7
+ data.tar.gz: 60ecac2ccad60019655d96623870256441f8683377ba7f014ea4a6198e3ab9d8387d4a031a1b6e1438cbedcd8f3acd4443b4c48a15c03174fb768aecf4170295
@@ -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
@@ -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.
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 = '001204'.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,7 +1,7 @@
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Yamada
@@ -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