uri 0.11.1 → 0.12.0
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 +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +3 -4
- data/lib/uri/common.rb +41 -11
- data/lib/uri/file.rb +6 -0
- data/lib/uri/generic.rb +12 -2
- data/lib/uri/mailto.rb +1 -1
- data/lib/uri/rfc3986_parser.rb +2 -3
- data/lib/uri/version.rb +1 -1
- data/lib/uri.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a80d9c44af3ea75a719aee7ec6d152ce0252b862baafc52458952321720334c3
|
4
|
+
data.tar.gz: 73a981c24af7b9f66afe406ad1a8aaf94e0af8e67b4d0cf0fbabec3b8a66153d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59b831894911f07c4c50717a3de80e5cfacc8720bb3ab2598da01d9de50552d0b4a7cff7263c4cd359f5908484e76ab07ae43d82ab9439b1b2184c7d0132552e
|
7
|
+
data.tar.gz: cf7054d37950fed4bbfa06dbdd2c3304f23b74c04817e36e7ad7887cceb4d8134feccaab35a9f1a20bcb6882ac5947d4f6518a83236f1d7555a2369bf31f2595
|
data/.github/workflows/test.yml
CHANGED
@@ -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@
|
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: bundle install
|
19
|
+
bundler-cache: true
|
21
20
|
- name: Run test
|
22
21
|
run: rake test
|
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!(
|
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
|
-
|
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(
|
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
data/lib/uri/rfc3986_parser.rb
CHANGED
@@ -2,9 +2,8 @@
|
|
2
2
|
module URI
|
3
3
|
class RFC3986_Parser # :nodoc:
|
4
4
|
# URI defined in RFC3986
|
5
|
-
|
6
|
-
|
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
|
data/lib/uri/version.rb
CHANGED
data/lib/uri.rb
CHANGED
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.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:
|
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.
|
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
|