uri 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.

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: 2dc19854507809e0f4bf6ae1fa81981c1efe1cd1a136569794d1998a9361ae1e
4
- data.tar.gz: 8d95b35877d847fa1f997760b7df2059cf0dfa6644c8a617e4a5abbab029d767
3
+ metadata.gz: a80d9c44af3ea75a719aee7ec6d152ce0252b862baafc52458952321720334c3
4
+ data.tar.gz: 73a981c24af7b9f66afe406ad1a8aaf94e0af8e67b4d0cf0fbabec3b8a66153d
5
5
  SHA512:
6
- metadata.gz: 7ea5bcaba6c135ec0b9c3f6441e5274087c9a8ad399297219e57b6ba03e4c944e113266e6a28964162de21367fa3881b9be7d9aa8ebf37536f5a8474b82a7c19
7
- data.tar.gz: 6996e26464dc1e408b82a926db2925d39633cb77d287944c09ed972fbf5eb87f513358439a8293874cfaf384621a4465d6c0fd2539b577c6faed305715453355
6
+ metadata.gz: 59b831894911f07c4c50717a3de80e5cfacc8720bb3ab2598da01d9de50552d0b4a7cff7263c4cd359f5908484e76ab07ae43d82ab9439b1b2184c7d0132552e
7
+ data.tar.gz: cf7054d37950fed4bbfa06dbdd2c3304f23b74c04817e36e7ad7887cceb4d8134feccaab35a9f1a20bcb6882ac5947d4f6518a83236f1d7555a2369bf31f2595
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
@@ -7,16 +7,15 @@ jobs:
7
7
  name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
8
  strategy:
9
9
  matrix:
10
- ruby: [ '3.0', 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@v2
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
- - name: Install dependencies
20
- run: bundle install
19
+ bundler-cache: true
21
20
  - name: Run test
22
21
  run: rake test
data/Gemfile CHANGED
@@ -6,5 +6,4 @@ group :development do
6
6
  gem "bundler"
7
7
  gem "rake"
8
8
  gem "test-unit"
9
- gem "test-unit-ruby-core"
10
9
  end
data/lib/uri/common.rb CHANGED
@@ -13,6 +13,8 @@ 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
@@ -62,14 +64,17 @@ module URI
62
64
  module_function :make_components_hash
63
65
  end
64
66
 
65
- include REGEXP
66
-
67
67
  module Schemes
68
68
  end
69
69
  private_constant :Schemes
70
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
+ #
71
76
  def self.register_scheme(scheme, klass)
72
- Schemes.const_set(scheme, klass)
77
+ Schemes.const_set(scheme.to_s.upcase, klass)
73
78
  end
74
79
 
75
80
  # Returns a Hash of the defined schemes.
@@ -295,6 +300,7 @@ module URI
295
300
  256.times do |i|
296
301
  TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
297
302
  end
303
+ TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
298
304
  TBLENCWWWCOMP_[' '] = '+'
299
305
  TBLENCWWWCOMP_.freeze
300
306
  TBLDECWWWCOMP_ = {} # :nodoc:
@@ -320,6 +326,33 @@ module URI
320
326
  #
321
327
  # See URI.decode_www_form_component, URI.encode_www_form.
322
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)
323
356
  str = str.to_s.dup
324
357
  if str.encoding != Encoding::ASCII_8BIT
325
358
  if enc && enc != Encoding::ASCII_8BIT
@@ -328,19 +361,16 @@ module URI
328
361
  end
329
362
  str.force_encoding(Encoding::ASCII_8BIT)
330
363
  end
331
- str.gsub!(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_)
364
+ str.gsub!(regexp, table)
332
365
  str.force_encoding(Encoding::US_ASCII)
333
366
  end
367
+ private_class_method :_encode_uri_component
334
368
 
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)
369
+ def self._decode_uri_component(regexp, str, enc)
341
370
  raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
342
- str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
371
+ str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
343
372
  end
373
+ private_class_method :_decode_uri_component
344
374
 
345
375
  # Generates URL-encoded form data from given +enum+.
346
376
  #
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
@@ -497,8 +497,8 @@ module URI
497
497
  ret = {}
498
498
 
499
499
  # for URI::split
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)
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)
502
502
 
503
503
  # for URI::extract
504
504
  ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
@@ -2,9 +2,8 @@
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/
7
- 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/
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/
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
 
10
9
  def initialize
@@ -101,7 +100,7 @@ module URI
101
100
  QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
102
101
  FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
103
102
  OPAQUE: /\A(?:[^\/].*)?\z/,
104
- PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
103
+ PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/,
105
104
  }
106
105
  end
107
106
 
data/lib/uri/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module URI
2
2
  # :stopdoc:
3
- VERSION_CODE = '001102'.freeze
3
+ VERSION_CODE = '001200'.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,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.12.0
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-06-29 00:00:00.000000000 Z
11
+ date: 2022-12-05 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
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
64
  - !ruby/object:Gem::Version
64
65
  version: '0'
65
66
  requirements: []
66
- rubygems_version: 3.3.26
67
+ rubygems_version: 3.4.0.dev
67
68
  signing_key:
68
69
  specification_version: 4
69
70
  summary: URI is a module providing classes to handle Uniform Resource Identifiers