uri 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e36cfa261a79542a5591ce20bc085a0f622baf08fd2492083187ccce7d892a7
4
- data.tar.gz: d3164253ba35cc1c531bc730d66fcda4e9731a7f086cf9a4e45d89005e50ab7c
3
+ metadata.gz: 90cdca72e248dc3cf6df707f34d7dcab07af72dbf959f4aca94366d60c5957a9
4
+ data.tar.gz: 5780324f560819375f5bf77aa64dd1e26306962906af94579ee121a8d0f3e897
5
5
  SHA512:
6
- metadata.gz: 58e1fe3612ceca21b12a36ca05aae94b5aabbb83b5f8949d5a1e059cb272aaeaa9383ae0dbc876fbd0a32db059a939d3f56462c70b07c9d622075f0c5d28309d
7
- data.tar.gz: bcbb9f2611ffd627d5ab13555bd5054c55536a2aff664022de31631ad8e825298bdcc9c06cf3d6c7cac1ef7c439d71b5e5f0c33e5e6fa8a287b2143cc145a756
6
+ metadata.gz: 525bd1d9e6626e0b16012072113c83c5e1c53feef99f10c3731683fb1ce52c23070eedcdc250b9998073a49fdcf3a78ad4ab96339e743c12a283c873323e2789
7
+ data.tar.gz: f2a660568adaf11db79134d2cbe82fc2c06067f91577413c92acd11a985bcdaed0016d8d76fe299890f221a86b8e7ef15c7a87d0eb210e428ffc4fd53c172a73
@@ -0,0 +1,24 @@
1
+ name: ubuntu
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
+ strategy:
9
+ matrix:
10
+ ruby: [ 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@master
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby }}
19
+ - name: Install dependencies
20
+ run: |
21
+ gem install bundler --no-document
22
+ bundle install
23
+ - name: Run test
24
+ run: rake test
data/README.md CHANGED
@@ -50,4 +50,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
50
50
 
51
51
  ## Contributing
52
52
 
53
- Bug reports and pull requests are welcome on GitHub at https://github.com/hsbt/uri.
53
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/uri.
data/lib/uri.rb CHANGED
@@ -86,7 +86,6 @@
86
86
  # License::
87
87
  # Copyright (c) 2001 akira yamada <akira@ruby-lang.org>
88
88
  # You can redistribute it and/or modify it under the same term as Ruby.
89
- # Revision:: $Id$
90
89
  #
91
90
 
92
91
  module URI
@@ -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
  #
@@ -61,82 +60,6 @@ module URI
61
60
  module_function :make_components_hash
62
61
  end
63
62
 
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
63
  include REGEXP
141
64
 
142
65
  @@schemes = {}
@@ -145,6 +68,20 @@ module URI
145
68
  @@schemes
146
69
  end
147
70
 
71
+ #
72
+ # Construct a URI instance, using the scheme to detect the appropriate class
73
+ # from +URI.scheme_list+.
74
+ #
75
+ def self.for(scheme, *arguments, default: Generic)
76
+ if scheme
77
+ uri_class = @@schemes[scheme.upcase] || default
78
+ else
79
+ uri_class = default
80
+ end
81
+
82
+ return uri_class.new(scheme, *arguments)
83
+ end
84
+
148
85
  #
149
86
  # Base class for all URI exceptions.
150
87
  #
@@ -315,7 +252,7 @@ module URI
315
252
  #
316
253
  # Returns a Regexp object which matches to URI-like strings.
317
254
  # The Regexp object returned by this method includes arbitrary
318
- # number of capture group (parentheses). Never rely on it's number.
255
+ # number of capture group (parentheses). Never rely on its number.
319
256
  #
320
257
  # == Usage
321
258
  #
@@ -362,7 +299,7 @@ module URI
362
299
  # If +enc+ is given, convert +str+ to the encoding before percent encoding.
363
300
  #
364
301
  # This is an implementation of
365
- # http://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
302
+ # https://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
366
303
  #
367
304
  # See URI.decode_www_form_component, URI.encode_www_form.
368
305
  def self.encode_www_form_component(str, enc=nil)
@@ -403,7 +340,7 @@ module URI
403
340
  # This method doesn't handle files. When you send a file, use
404
341
  # multipart/form-data.
405
342
  #
406
- # This refers http://url.spec.whatwg.org/#concept-urlencoded-serializer
343
+ # This refers https://url.spec.whatwg.org/#concept-urlencoded-serializer
407
344
  #
408
345
  # URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
409
346
  # #=> "q=ruby&lang=en"
@@ -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
  #
@@ -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
  #
@@ -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.send(:convert_to_uri, oth)
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.send(:convert_to_uri, oth)
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.send(:convert_to_uri, oth).route_from(self)
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.send(x)
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.send(c)
1432
+ self.__send__(c)
1434
1433
  else
1435
1434
  raise ArgumentError,
1436
1435
  "expected of components of #{self.class} (#{self.class.component.join(', ')})"
@@ -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
  #
@@ -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
  #
@@ -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
@@ -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
  #
@@ -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
  #
@@ -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
- scheme, userinfo, host, port,
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
  #
@@ -69,18 +69,7 @@ module URI
69
69
  end
70
70
 
71
71
  def parse(uri) # :nodoc:
72
- scheme, userinfo, host, port,
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
 
@@ -1,6 +1,6 @@
1
1
  module URI
2
2
  # :stopdoc:
3
- VERSION_CODE = '001000'.freeze
3
+ VERSION_CODE = '001001'.freeze
4
4
  VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
5
5
  # :startdoc:
6
6
  end
@@ -0,0 +1,84 @@
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
+ @@schemes['WS'] = WS
83
+
84
+ end
@@ -0,0 +1,22 @@
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
+ @@schemes['WSS'] = WSS
22
+ end
@@ -13,7 +13,7 @@ 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.license = "BSD-2-Clause"
16
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
17
17
 
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = spec.homepage
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
23
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
25
  end
26
26
  spec.bindir = "exe"
27
27
  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.10.0
4
+ version: 0.10.1
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: 2020-04-01 00:00:00.000000000 Z
11
+ date: 2020-12-22 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
@@ -60,8 +63,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
63
  - !ruby/object:Gem::Version
61
64
  version: '0'
62
65
  requirements: []
63
- rubygems_version: 3.2.0.pre1
64
- signing_key:
66
+ rubygems_version: 3.2.2
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: []
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 2.0.2