uri 0.10.0 → 0.11.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/workflows/test.yml +22 -0
- data/README.md +4 -3
- data/Rakefile +9 -2
- data/lib/uri/common.rb +38 -83
- data/lib/uri/file.rb +1 -1
- data/lib/uri/ftp.rb +2 -2
- data/lib/uri/generic.rb +20 -11
- data/lib/uri/http.rb +40 -3
- data/lib/uri/https.rb +2 -2
- data/lib/uri/ldap.rb +2 -2
- data/lib/uri/ldaps.rb +2 -1
- data/lib/uri/mailto.rb +1 -2
- data/lib/uri/rfc2396_parser.rb +14 -21
- data/lib/uri/rfc3986_parser.rb +9 -14
- data/lib/uri/version.rb +1 -1
- data/lib/uri/ws.rb +83 -0
- data/lib/uri/wss.rb +23 -0
- data/lib/uri.rb +2 -3
- data/uri.gemspec +4 -2
- metadata +11 -8
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7d8f9f16782c6d943477fcd62e6cc5799e7a08a9139fe301be0aa378805ea94
|
4
|
+
data.tar.gz: 24ce150ab74ba59971c8e5383a3901b1fc00decf672c89533cbece16283727af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 376958fe2bd228dd4baff525452637cbb0af013cc93313f71c64821b75459f868a3c10ea11fdbe2093975de52669175866c1b4c9b38e594d756b1692d2976bc4
|
7
|
+
data.tar.gz: f57a16492c7ad239a29228e7dcb0f9cdb89b54a37c24e3a39677927fb3cf46f9899f1a2977f2542e1b5bd93adcbbeba8a0b7d0790c798a70dd7a07d2312034b7
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: [ '3.0', 2.7, 2.6, 2.5, 2.4, head ]
|
11
|
+
os: [ ubuntu-latest, macos-latest ]
|
12
|
+
runs-on: ${{ matrix.os }}
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Set up Ruby
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby }}
|
19
|
+
- name: Install dependencies
|
20
|
+
run: bundle install
|
21
|
+
- name: Run test
|
22
|
+
run: rake test
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# URI
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
[](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
|
|
@@ -50,4 +51,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
50
51
|
|
51
52
|
## Contributing
|
52
53
|
|
53
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
54
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/uri.
|
data/Rakefile
CHANGED
@@ -2,9 +2,16 @@ require "bundler/gem_tasks"
|
|
2
2
|
require "rake/testtask"
|
3
3
|
|
4
4
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << "test
|
6
|
-
t.
|
5
|
+
t.libs << "test/lib"
|
6
|
+
t.ruby_opts << "-rhelper"
|
7
7
|
t.test_files = FileList["test/**/test_*.rb"]
|
8
8
|
end
|
9
9
|
|
10
|
+
task :sync_tool do
|
11
|
+
require 'fileutils'
|
12
|
+
FileUtils.cp "../ruby/tool/lib/test/unit/core_assertions.rb", "./test/lib"
|
13
|
+
FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
|
14
|
+
FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
|
15
|
+
end
|
16
|
+
|
10
17
|
task :default => :test
|
data/lib/uri/common.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
# = uri/common.rb
|
4
4
|
#
|
5
5
|
# Author:: Akira Yamada <akira@ruby-lang.org>
|
6
|
-
# Revision:: $Id$
|
7
6
|
# License::
|
8
7
|
# You can redistribute it and/or modify it under the same term as Ruby.
|
9
8
|
#
|
@@ -17,6 +16,7 @@ module URI
|
|
17
16
|
REGEXP = RFC2396_REGEXP
|
18
17
|
Parser = RFC2396_Parser
|
19
18
|
RFC3986_PARSER = RFC3986_Parser.new
|
19
|
+
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
|
20
20
|
|
21
21
|
# URI::Parser.new
|
22
22
|
DEFAULT_PARSER = Parser.new
|
@@ -28,6 +28,7 @@ module URI
|
|
28
28
|
DEFAULT_PARSER.regexp.each_pair do |sym, str|
|
29
29
|
const_set(sym, str)
|
30
30
|
end
|
31
|
+
Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
|
31
32
|
|
32
33
|
module Util # :nodoc:
|
33
34
|
def make_components_hash(klass, array_hash)
|
@@ -61,88 +62,41 @@ module URI
|
|
61
62
|
module_function :make_components_hash
|
62
63
|
end
|
63
64
|
|
64
|
-
# Module for escaping unsafe characters with codes.
|
65
|
-
module Escape
|
66
|
-
#
|
67
|
-
# == Synopsis
|
68
|
-
#
|
69
|
-
# URI.escape(str [, unsafe])
|
70
|
-
#
|
71
|
-
# == Args
|
72
|
-
#
|
73
|
-
# +str+::
|
74
|
-
# String to replaces in.
|
75
|
-
# +unsafe+::
|
76
|
-
# Regexp that matches all symbols that must be replaced with codes.
|
77
|
-
# By default uses <tt>UNSAFE</tt>.
|
78
|
-
# When this argument is a String, it represents a character set.
|
79
|
-
#
|
80
|
-
# == Description
|
81
|
-
#
|
82
|
-
# Escapes the string, replacing all unsafe characters with codes.
|
83
|
-
#
|
84
|
-
# This method is obsolete and should not be used. Instead, use
|
85
|
-
# CGI.escape, URI.encode_www_form or URI.encode_www_form_component
|
86
|
-
# depending on your specific use case.
|
87
|
-
#
|
88
|
-
# == Usage
|
89
|
-
#
|
90
|
-
# require 'uri'
|
91
|
-
#
|
92
|
-
# enc_uri = URI.escape("http://example.com/?a=\11\15")
|
93
|
-
# # => "http://example.com/?a=%09%0D"
|
94
|
-
#
|
95
|
-
# URI.unescape(enc_uri)
|
96
|
-
# # => "http://example.com/?a=\t\r"
|
97
|
-
#
|
98
|
-
# URI.escape("@?@!", "!?")
|
99
|
-
# # => "@%3F@%21"
|
100
|
-
#
|
101
|
-
def escape(*arg)
|
102
|
-
warn "URI.escape is obsolete", uplevel: 1
|
103
|
-
DEFAULT_PARSER.escape(*arg)
|
104
|
-
end
|
105
|
-
alias encode escape
|
106
|
-
#
|
107
|
-
# == Synopsis
|
108
|
-
#
|
109
|
-
# URI.unescape(str)
|
110
|
-
#
|
111
|
-
# == Args
|
112
|
-
#
|
113
|
-
# +str+::
|
114
|
-
# String to unescape.
|
115
|
-
#
|
116
|
-
# == Description
|
117
|
-
#
|
118
|
-
# This method is obsolete and should not be used. Instead, use
|
119
|
-
# CGI.unescape, URI.decode_www_form or URI.decode_www_form_component
|
120
|
-
# depending on your specific use case.
|
121
|
-
#
|
122
|
-
# == Usage
|
123
|
-
#
|
124
|
-
# require 'uri'
|
125
|
-
#
|
126
|
-
# enc_uri = URI.escape("http://example.com/?a=\11\15")
|
127
|
-
# # => "http://example.com/?a=%09%0D"
|
128
|
-
#
|
129
|
-
# URI.unescape(enc_uri)
|
130
|
-
# # => "http://example.com/?a=\t\r"
|
131
|
-
#
|
132
|
-
def unescape(*arg)
|
133
|
-
warn "URI.unescape is obsolete", uplevel: 1
|
134
|
-
DEFAULT_PARSER.unescape(*arg)
|
135
|
-
end
|
136
|
-
alias decode unescape
|
137
|
-
end # module Escape
|
138
|
-
|
139
|
-
extend Escape
|
140
65
|
include REGEXP
|
141
66
|
|
142
|
-
|
67
|
+
module Schemes
|
68
|
+
end
|
69
|
+
private_constant :Schemes
|
70
|
+
|
71
|
+
def self.register_scheme(scheme, klass)
|
72
|
+
Schemes.const_set(scheme, klass)
|
73
|
+
end
|
74
|
+
|
143
75
|
# Returns a Hash of the defined schemes.
|
144
76
|
def self.scheme_list
|
145
|
-
|
77
|
+
Schemes.constants.map { |name|
|
78
|
+
[name.to_s.upcase, Schemes.const_get(name)]
|
79
|
+
}.to_h
|
80
|
+
end
|
81
|
+
|
82
|
+
INITIAL_SCHEMES = scheme_list
|
83
|
+
private_constant :INITIAL_SCHEMES
|
84
|
+
Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
|
85
|
+
|
86
|
+
#
|
87
|
+
# Construct a URI instance, using the scheme to detect the appropriate class
|
88
|
+
# from +URI.scheme_list+.
|
89
|
+
#
|
90
|
+
def self.for(scheme, *arguments, default: Generic)
|
91
|
+
const_name = scheme.to_s.upcase
|
92
|
+
|
93
|
+
uri_class = INITIAL_SCHEMES[const_name]
|
94
|
+
uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
|
95
|
+
Schemes.const_get(const_name, false)
|
96
|
+
end
|
97
|
+
uri_class ||= default
|
98
|
+
|
99
|
+
return uri_class.new(scheme, *arguments)
|
146
100
|
end
|
147
101
|
|
148
102
|
#
|
@@ -315,7 +269,7 @@ module URI
|
|
315
269
|
#
|
316
270
|
# Returns a Regexp object which matches to URI-like strings.
|
317
271
|
# The Regexp object returned by this method includes arbitrary
|
318
|
-
# number of capture group (parentheses). Never rely on
|
272
|
+
# number of capture group (parentheses). Never rely on its number.
|
319
273
|
#
|
320
274
|
# == Usage
|
321
275
|
#
|
@@ -362,7 +316,7 @@ module URI
|
|
362
316
|
# If +enc+ is given, convert +str+ to the encoding before percent encoding.
|
363
317
|
#
|
364
318
|
# This is an implementation of
|
365
|
-
#
|
319
|
+
# https://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
|
366
320
|
#
|
367
321
|
# See URI.decode_www_form_component, URI.encode_www_form.
|
368
322
|
def self.encode_www_form_component(str, enc=nil)
|
@@ -384,7 +338,7 @@ module URI
|
|
384
338
|
#
|
385
339
|
# See URI.encode_www_form_component, URI.decode_www_form.
|
386
340
|
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
387
|
-
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)
|
341
|
+
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
|
388
342
|
str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
|
389
343
|
end
|
390
344
|
|
@@ -403,7 +357,7 @@ module URI
|
|
403
357
|
# This method doesn't handle files. When you send a file, use
|
404
358
|
# multipart/form-data.
|
405
359
|
#
|
406
|
-
# This refers
|
360
|
+
# This refers https://url.spec.whatwg.org/#concept-urlencoded-serializer
|
407
361
|
#
|
408
362
|
# URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
|
409
363
|
# #=> "q=ruby&lang=en"
|
@@ -716,6 +670,7 @@ module URI
|
|
716
670
|
"utf-16"=>"utf-16le",
|
717
671
|
"utf-16le"=>"utf-16le",
|
718
672
|
} # :nodoc:
|
673
|
+
Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
|
719
674
|
|
720
675
|
# :nodoc:
|
721
676
|
# return encoding or nil
|
data/lib/uri/file.rb
CHANGED
data/lib/uri/ftp.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# Author:: Akira Yamada <akira@ruby-lang.org>
|
5
5
|
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
6
|
-
# Revision:: $Id$
|
7
6
|
#
|
8
7
|
# See URI for general documentation
|
9
8
|
#
|
@@ -263,5 +262,6 @@ module URI
|
|
263
262
|
return str
|
264
263
|
end
|
265
264
|
end
|
266
|
-
|
265
|
+
|
266
|
+
register_scheme 'FTP', FTP
|
267
267
|
end
|
data/lib/uri/generic.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
#
|
5
5
|
# Author:: Akira Yamada <akira@ruby-lang.org>
|
6
6
|
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
7
|
-
# Revision:: $Id$
|
8
7
|
#
|
9
8
|
# See URI for general documentation
|
10
9
|
#
|
@@ -644,7 +643,7 @@ module URI
|
|
644
643
|
#
|
645
644
|
def hostname
|
646
645
|
v = self.host
|
647
|
-
|
646
|
+
v&.start_with?('[') && v.end_with?(']') ? v[1..-2] : v
|
648
647
|
end
|
649
648
|
|
650
649
|
# Sets the host part of the URI as the argument with brackets for IPv6 addresses.
|
@@ -660,7 +659,7 @@ module URI
|
|
660
659
|
# it is wrapped with brackets.
|
661
660
|
#
|
662
661
|
def hostname=(v)
|
663
|
-
v = "[#{v}]" if
|
662
|
+
v = "[#{v}]" if !(v&.start_with?('[') && v&.end_with?(']')) && v&.index(':')
|
664
663
|
self.host = v
|
665
664
|
end
|
666
665
|
|
@@ -1098,7 +1097,7 @@ module URI
|
|
1098
1097
|
# # => "http://my.example.com/main.rbx?page=1"
|
1099
1098
|
#
|
1100
1099
|
def merge(oth)
|
1101
|
-
rel = parser.
|
1100
|
+
rel = parser.__send__(:convert_to_uri, oth)
|
1102
1101
|
|
1103
1102
|
if rel.absolute?
|
1104
1103
|
#raise BadURIError, "both URI are absolute" if absolute?
|
@@ -1183,7 +1182,7 @@ module URI
|
|
1183
1182
|
|
1184
1183
|
# :stopdoc:
|
1185
1184
|
def route_from0(oth)
|
1186
|
-
oth = parser.
|
1185
|
+
oth = parser.__send__(:convert_to_uri, oth)
|
1187
1186
|
if self.relative?
|
1188
1187
|
raise BadURIError,
|
1189
1188
|
"relative URI: #{self}"
|
@@ -1291,7 +1290,7 @@ module URI
|
|
1291
1290
|
# #=> #<URI::Generic /main.rbx?page=1>
|
1292
1291
|
#
|
1293
1292
|
def route_to(oth)
|
1294
|
-
parser.
|
1293
|
+
parser.__send__(:convert_to_uri, oth).route_from(self)
|
1295
1294
|
end
|
1296
1295
|
|
1297
1296
|
#
|
@@ -1405,7 +1404,7 @@ module URI
|
|
1405
1404
|
# Returns an Array of the components defined from the COMPONENT Array.
|
1406
1405
|
def component_ary
|
1407
1406
|
component.collect do |x|
|
1408
|
-
self.
|
1407
|
+
self.__send__(x)
|
1409
1408
|
end
|
1410
1409
|
end
|
1411
1410
|
protected :component_ary
|
@@ -1430,7 +1429,7 @@ module URI
|
|
1430
1429
|
def select(*components)
|
1431
1430
|
components.collect do |c|
|
1432
1431
|
if component.include?(c)
|
1433
|
-
self.
|
1432
|
+
self.__send__(c)
|
1434
1433
|
else
|
1435
1434
|
raise ArgumentError,
|
1436
1435
|
"expected of components of #{self.class} (#{self.class.component.join(', ')})"
|
@@ -1515,9 +1514,19 @@ module URI
|
|
1515
1514
|
proxy_uri = env["CGI_#{name.upcase}"]
|
1516
1515
|
end
|
1517
1516
|
elsif name == 'http_proxy'
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1517
|
+
if RUBY_ENGINE == 'jruby' && p_addr = ENV_JAVA['http.proxyHost']
|
1518
|
+
p_port = ENV_JAVA['http.proxyPort']
|
1519
|
+
if p_user = ENV_JAVA['http.proxyUser']
|
1520
|
+
p_pass = ENV_JAVA['http.proxyPass']
|
1521
|
+
proxy_uri = "http://#{p_user}:#{p_pass}@#{p_addr}:#{p_port}"
|
1522
|
+
else
|
1523
|
+
proxy_uri = "http://#{p_addr}:#{p_port}"
|
1524
|
+
end
|
1525
|
+
else
|
1526
|
+
unless proxy_uri = env[name]
|
1527
|
+
if proxy_uri = env[name.upcase]
|
1528
|
+
warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.', uplevel: 1
|
1529
|
+
end
|
1521
1530
|
end
|
1522
1531
|
end
|
1523
1532
|
else
|
data/lib/uri/http.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# Author:: Akira Yamada <akira@ruby-lang.org>
|
5
5
|
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
6
|
-
# Revision:: $Id$
|
7
6
|
#
|
8
7
|
# See URI for general documentation
|
9
8
|
#
|
@@ -81,8 +80,46 @@ module URI
|
|
81
80
|
url = @query ? "#@path?#@query" : @path.dup
|
82
81
|
url.start_with?(?/.freeze) ? url : ?/ + url
|
83
82
|
end
|
84
|
-
end
|
85
83
|
|
86
|
-
|
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
|
87
123
|
|
124
|
+
register_scheme 'HTTP', HTTP
|
88
125
|
end
|
data/lib/uri/https.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# Author:: Akira Yamada <akira@ruby-lang.org>
|
5
5
|
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
6
|
-
# Revision:: $Id$
|
7
6
|
#
|
8
7
|
# See URI for general documentation
|
9
8
|
#
|
@@ -19,5 +18,6 @@ module URI
|
|
19
18
|
# A Default port of 443 for URI::HTTPS
|
20
19
|
DEFAULT_PORT = 443
|
21
20
|
end
|
22
|
-
|
21
|
+
|
22
|
+
register_scheme 'HTTPS', HTTPS
|
23
23
|
end
|
data/lib/uri/ldap.rb
CHANGED
@@ -7,7 +7,6 @@
|
|
7
7
|
# License::
|
8
8
|
# URI::LDAP is copyrighted free software by Takaaki Tateishi and Akira Yamada.
|
9
9
|
# You can redistribute it and/or modify it under the same term as Ruby.
|
10
|
-
# Revision:: $Id$
|
11
10
|
#
|
12
11
|
# See URI for general documentation
|
13
12
|
#
|
@@ -119,6 +118,7 @@ module URI
|
|
119
118
|
|
120
119
|
# Private method to cleanup +dn+ from using the +path+ component attribute.
|
121
120
|
def parse_dn
|
121
|
+
raise InvalidURIError, 'bad LDAP URL' unless @path
|
122
122
|
@dn = @path[1..-1]
|
123
123
|
end
|
124
124
|
private :parse_dn
|
@@ -257,5 +257,5 @@ module URI
|
|
257
257
|
end
|
258
258
|
end
|
259
259
|
|
260
|
-
|
260
|
+
register_scheme 'LDAP', LDAP
|
261
261
|
end
|
data/lib/uri/ldaps.rb
CHANGED
data/lib/uri/mailto.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# Author:: Akira Yamada <akira@ruby-lang.org>
|
5
5
|
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
6
|
-
# Revision:: $Id$
|
7
6
|
#
|
8
7
|
# See URI for general documentation
|
9
8
|
#
|
@@ -290,5 +289,5 @@ module URI
|
|
290
289
|
alias to_rfc822text to_mailtext
|
291
290
|
end
|
292
291
|
|
293
|
-
|
292
|
+
register_scheme 'MAILTO', MailTo
|
294
293
|
end
|
data/lib/uri/rfc2396_parser.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
# = uri/common.rb
|
4
4
|
#
|
5
5
|
# Author:: Akira Yamada <akira@ruby-lang.org>
|
6
|
-
# Revision:: $Id$
|
7
6
|
# License::
|
8
7
|
# You can redistribute it and/or modify it under the same term as Ruby.
|
9
8
|
#
|
@@ -117,7 +116,7 @@ module URI
|
|
117
116
|
# See also URI::Parser.initialize_regexp.
|
118
117
|
attr_reader :regexp
|
119
118
|
|
120
|
-
# Returns a split URI against regexp[:ABS_URI]
|
119
|
+
# Returns a split URI against +regexp[:ABS_URI]+.
|
121
120
|
def split(uri)
|
122
121
|
case uri
|
123
122
|
when ''
|
@@ -208,21 +207,9 @@ module URI
|
|
208
207
|
# #=> #<URI::LDAP ldap://ldap.example.com/dc=example?user=john>
|
209
208
|
#
|
210
209
|
def parse(uri)
|
211
|
-
|
212
|
-
registry, path, opaque, query, fragment = self.split(uri)
|
213
|
-
|
214
|
-
if scheme && URI.scheme_list.include?(scheme.upcase)
|
215
|
-
URI.scheme_list[scheme.upcase].new(scheme, userinfo, host, port,
|
216
|
-
registry, path, opaque, query,
|
217
|
-
fragment, self)
|
218
|
-
else
|
219
|
-
Generic.new(scheme, userinfo, host, port,
|
220
|
-
registry, path, opaque, query,
|
221
|
-
fragment, self)
|
222
|
-
end
|
210
|
+
URI.for(*self.split(uri), self)
|
223
211
|
end
|
224
212
|
|
225
|
-
|
226
213
|
#
|
227
214
|
# == Args
|
228
215
|
#
|
@@ -270,8 +257,8 @@ module URI
|
|
270
257
|
end
|
271
258
|
end
|
272
259
|
|
273
|
-
# Returns Regexp that is default self.regexp[:ABS_URI_REF]
|
274
|
-
# 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]+.
|
275
262
|
def make_regexp(schemes = nil)
|
276
263
|
unless schemes
|
277
264
|
@regexp[:ABS_URI_REF]
|
@@ -290,7 +277,7 @@ module URI
|
|
290
277
|
# +str+::
|
291
278
|
# String to make safe
|
292
279
|
# +unsafe+::
|
293
|
-
# Regexp to apply. Defaults to self.regexp[:UNSAFE]
|
280
|
+
# Regexp to apply. Defaults to +self.regexp[:UNSAFE]+
|
294
281
|
#
|
295
282
|
# == Description
|
296
283
|
#
|
@@ -322,7 +309,7 @@ module URI
|
|
322
309
|
# +str+::
|
323
310
|
# String to remove escapes from
|
324
311
|
# +escaped+::
|
325
|
-
# Regexp to apply. Defaults to self.regexp[:ESCAPED]
|
312
|
+
# Regexp to apply. Defaults to +self.regexp[:ESCAPED]+
|
326
313
|
#
|
327
314
|
# == Description
|
328
315
|
#
|
@@ -335,8 +322,14 @@ module URI
|
|
335
322
|
end
|
336
323
|
|
337
324
|
@@to_s = Kernel.instance_method(:to_s)
|
338
|
-
|
339
|
-
|
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
|
340
333
|
end
|
341
334
|
|
342
335
|
private
|
data/lib/uri/rfc3986_parser.rb
CHANGED
@@ -69,18 +69,7 @@ module URI
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def parse(uri) # :nodoc:
|
72
|
-
|
73
|
-
registry, path, opaque, query, fragment = self.split(uri)
|
74
|
-
scheme_list = URI.scheme_list
|
75
|
-
if scheme && scheme_list.include?(uc = scheme.upcase)
|
76
|
-
scheme_list[uc].new(scheme, userinfo, host, port,
|
77
|
-
registry, path, opaque, query,
|
78
|
-
fragment, self)
|
79
|
-
else
|
80
|
-
Generic.new(scheme, userinfo, host, port,
|
81
|
-
registry, path, opaque, query,
|
82
|
-
fragment, self)
|
83
|
-
end
|
72
|
+
URI.for(*self.split(uri), self)
|
84
73
|
end
|
85
74
|
|
86
75
|
|
@@ -90,8 +79,14 @@ module URI
|
|
90
79
|
end
|
91
80
|
|
92
81
|
@@to_s = Kernel.instance_method(:to_s)
|
93
|
-
|
94
|
-
|
82
|
+
if @@to_s.respond_to?(:bind_call)
|
83
|
+
def inspect
|
84
|
+
@@to_s.bind_call(self)
|
85
|
+
end
|
86
|
+
else
|
87
|
+
def inspect
|
88
|
+
@@to_s.bind(self).call
|
89
|
+
end
|
95
90
|
end
|
96
91
|
|
97
92
|
private
|
data/lib/uri/version.rb
CHANGED
data/lib/uri/ws.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
# = uri/ws.rb
|
3
|
+
#
|
4
|
+
# Author:: Matt Muller <mamuller@amazon.com>
|
5
|
+
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
6
|
+
#
|
7
|
+
# See URI for general documentation
|
8
|
+
#
|
9
|
+
|
10
|
+
require_relative 'generic'
|
11
|
+
|
12
|
+
module URI
|
13
|
+
|
14
|
+
#
|
15
|
+
# The syntax of WS URIs is defined in RFC6455 section 3.
|
16
|
+
#
|
17
|
+
# Note that the Ruby URI library allows WS URLs containing usernames and
|
18
|
+
# passwords. This is not legal as per the RFC, but used to be
|
19
|
+
# supported in Internet Explorer 5 and 6, before the MS04-004 security
|
20
|
+
# update. See <URL:http://support.microsoft.com/kb/834489>.
|
21
|
+
#
|
22
|
+
class WS < Generic
|
23
|
+
# A Default port of 80 for URI::WS.
|
24
|
+
DEFAULT_PORT = 80
|
25
|
+
|
26
|
+
# An Array of the available components for URI::WS.
|
27
|
+
COMPONENT = %i[
|
28
|
+
scheme
|
29
|
+
userinfo host port
|
30
|
+
path
|
31
|
+
query
|
32
|
+
].freeze
|
33
|
+
|
34
|
+
#
|
35
|
+
# == Description
|
36
|
+
#
|
37
|
+
# Creates a new URI::WS object from components, with syntax checking.
|
38
|
+
#
|
39
|
+
# The components accepted are userinfo, host, port, path, and query.
|
40
|
+
#
|
41
|
+
# The components should be provided either as an Array, or as a Hash
|
42
|
+
# with keys formed by preceding the component names with a colon.
|
43
|
+
#
|
44
|
+
# If an Array is used, the components must be passed in the
|
45
|
+
# order <code>[userinfo, host, port, path, query]</code>.
|
46
|
+
#
|
47
|
+
# Example:
|
48
|
+
#
|
49
|
+
# uri = URI::WS.build(host: 'www.example.com', path: '/foo/bar')
|
50
|
+
#
|
51
|
+
# uri = URI::WS.build([nil, "www.example.com", nil, "/path", "query"])
|
52
|
+
#
|
53
|
+
# Currently, if passed userinfo components this method generates
|
54
|
+
# invalid WS URIs as per RFC 1738.
|
55
|
+
#
|
56
|
+
def self.build(args)
|
57
|
+
tmp = Util.make_components_hash(self, args)
|
58
|
+
super(tmp)
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# == Description
|
63
|
+
#
|
64
|
+
# Returns the full path for a WS URI, as required by Net::HTTP::Get.
|
65
|
+
#
|
66
|
+
# If the URI contains a query, the full path is URI#path + '?' + URI#query.
|
67
|
+
# Otherwise, the path is simply URI#path.
|
68
|
+
#
|
69
|
+
# Example:
|
70
|
+
#
|
71
|
+
# uri = URI::WS.build(path: '/foo/bar', query: 'test=true')
|
72
|
+
# uri.request_uri # => "/foo/bar?test=true"
|
73
|
+
#
|
74
|
+
def request_uri
|
75
|
+
return unless @path
|
76
|
+
|
77
|
+
url = @query ? "#@path?#@query" : @path.dup
|
78
|
+
url.start_with?(?/.freeze) ? url : ?/ + url
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
register_scheme 'WS', WS
|
83
|
+
end
|
data/lib/uri/wss.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
# = uri/wss.rb
|
3
|
+
#
|
4
|
+
# Author:: Matt Muller <mamuller@amazon.com>
|
5
|
+
# License:: You can redistribute it and/or modify it under the same term as Ruby.
|
6
|
+
#
|
7
|
+
# See URI for general documentation
|
8
|
+
#
|
9
|
+
|
10
|
+
require_relative 'ws'
|
11
|
+
|
12
|
+
module URI
|
13
|
+
|
14
|
+
# The default port for WSS URIs is 443, and the scheme is 'wss:' rather
|
15
|
+
# than 'ws:'. Other than that, WSS URIs are identical to WS URIs;
|
16
|
+
# see URI::WS.
|
17
|
+
class WSS < WS
|
18
|
+
# A Default port of 443 for URI::WSS
|
19
|
+
DEFAULT_PORT = 443
|
20
|
+
end
|
21
|
+
|
22
|
+
register_scheme 'WSS', WSS
|
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
|
-
#
|
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)
|
@@ -86,7 +85,6 @@
|
|
86
85
|
# License::
|
87
86
|
# Copyright (c) 2001 akira yamada <akira@ruby-lang.org>
|
88
87
|
# You can redistribute it and/or modify it under the same term as Ruby.
|
89
|
-
# Revision:: $Id$
|
90
88
|
#
|
91
89
|
|
92
90
|
module URI
|
@@ -102,3 +100,4 @@ require_relative 'uri/https'
|
|
102
100
|
require_relative 'uri/ldap'
|
103
101
|
require_relative 'uri/ldaps'
|
104
102
|
require_relative 'uri/mailto'
|
103
|
+
require_relative 'uri/ws'
|
data/uri.gemspec
CHANGED
@@ -13,7 +13,9 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.summary = %q{URI is a module providing classes to handle Uniform Resource Identifiers}
|
14
14
|
spec.description = spec.summary
|
15
15
|
spec.homepage = "https://github.com/ruby/uri"
|
16
|
-
spec.
|
16
|
+
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
17
|
+
|
18
|
+
spec.required_ruby_version = '>= 2.4'
|
17
19
|
|
18
20
|
spec.metadata["homepage_uri"] = spec.homepage
|
19
21
|
spec.metadata["source_code_uri"] = spec.homepage
|
@@ -21,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
21
23
|
# Specify which files should be added to the gem when it is released.
|
22
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
25
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
`git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
27
|
end
|
26
28
|
spec.bindir = "exe"
|
27
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
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.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Yamada
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-21 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,8 +17,8 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/workflows/test.yml"
|
20
21
|
- ".gitignore"
|
21
|
-
- ".travis.yml"
|
22
22
|
- Gemfile
|
23
23
|
- LICENSE.txt
|
24
24
|
- README.md
|
@@ -38,14 +38,17 @@ files:
|
|
38
38
|
- lib/uri/rfc2396_parser.rb
|
39
39
|
- lib/uri/rfc3986_parser.rb
|
40
40
|
- lib/uri/version.rb
|
41
|
+
- lib/uri/ws.rb
|
42
|
+
- lib/uri/wss.rb
|
41
43
|
- uri.gemspec
|
42
44
|
homepage: https://github.com/ruby/uri
|
43
45
|
licenses:
|
46
|
+
- Ruby
|
44
47
|
- BSD-2-Clause
|
45
48
|
metadata:
|
46
49
|
homepage_uri: https://github.com/ruby/uri
|
47
50
|
source_code_uri: https://github.com/ruby/uri
|
48
|
-
post_install_message:
|
51
|
+
post_install_message:
|
49
52
|
rdoc_options: []
|
50
53
|
require_paths:
|
51
54
|
- lib
|
@@ -53,15 +56,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
56
|
requirements:
|
54
57
|
- - ">="
|
55
58
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
59
|
+
version: '2.4'
|
57
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
61
|
requirements:
|
59
62
|
- - ">="
|
60
63
|
- !ruby/object:Gem::Version
|
61
64
|
version: '0'
|
62
65
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
64
|
-
signing_key:
|
66
|
+
rubygems_version: 3.3.0.dev
|
67
|
+
signing_key:
|
65
68
|
specification_version: 4
|
66
69
|
summary: URI is a module providing classes to handle Uniform Resource Identifiers
|
67
70
|
test_files: []
|