addressable 2.8.4 → 2.8.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9be949fe19003ebc13db9a486fe0bb50b488896fa1671a3dc5ac2cd62e30c875
4
- data.tar.gz: '01824780e0172f78d7bf95857b4546e47b32a50426c2d953a07f9d1c63f37af3'
3
+ metadata.gz: 62b62e368b9dffbec4c9aaf879257067698b83daff1cc13542352da419f3f88e
4
+ data.tar.gz: 7f3231aecc91ef0c3087ff2325d78e9a1f4c9f05a752f2c35c8f0bb740fd5996
5
5
  SHA512:
6
- metadata.gz: 051d1501ab89efff21d5bcc3aed23bec2f7ff2defdf21915455142d7c1382e6b734053162dc9a19a9ba5946e9978ff6baa305035ebea5f947ba48e6241973059
7
- data.tar.gz: 7cca09d71ccbb21e116ddb36075ab1fab39078dc5b51b9c7c34df8a88db3d90f8158c8c066692997fd551c97e983e6a9ddec3054741ee1337a9c185cca1c8a88
6
+ metadata.gz: 670e1aeddc5a4f62ad39040007cef7371107237b2e4064755355dfbc43cfc62a956f78358c95793a9f55cd325b7b46ce532003bdd9711b1bc3c79b35e0d3cbf6
7
+ data.tar.gz: d7aed8469d926b0bcdd19202593f8bfa162d9dafb38dabca632ccee8af3fd26920dfbce3f18b674d583f5aaa2e7c51717ccf46fab3a1a4fb4a8dfbd74a80da16
data/CHANGELOG.md CHANGED
@@ -1,15 +1,34 @@
1
- # Addressable 2.8.4
1
+ # Addressable 2.8.7 <a name="v2.8.7">
2
+ - Allow `public_suffix` 6 ([#535])
3
+
4
+ [#535]: https://github.com/sporkmonger/addressable/pull/535
5
+
6
+ # Addressable 2.8.6 <a name="v2.8.6">
7
+ - Memoize regexps for common character classes ([#524])
8
+
9
+ [#524]: https://github.com/sporkmonger/addressable/pull/524
10
+
11
+ # Addressable 2.8.5 <a name="v2.8.5">
12
+ - Fix thread safety issue with encoding tables ([#515])
13
+ - Define URI::NONE as a module to avoid serialization issues ([#509])
14
+ - Fix YAML serialization ([#508])
15
+
16
+ [#508]: https://github.com/sporkmonger/addressable/pull/508
17
+ [#509]: https://github.com/sporkmonger/addressable/pull/509
18
+ [#515]: https://github.com/sporkmonger/addressable/pull/515
19
+
20
+ # Addressable 2.8.4 <a name="v2.8.4">
2
21
  - Restore `Addressable::IDNA.unicode_normalize_kc` as a deprecated method ([#504])
3
22
 
4
23
  [#504]: https://github.com/sporkmonger/addressable/pull/504
5
24
 
6
- # Addressable 2.8.3
25
+ # Addressable 2.8.3 <a name="v2.8.3">
7
26
  - Fix template expand level 2 hash support for non-string objects ([#499], [#498])
8
27
 
9
28
  [#499]: https://github.com/sporkmonger/addressable/pull/499
10
29
  [#498]: https://github.com/sporkmonger/addressable/pull/498
11
30
 
12
- # Addressable 2.8.2
31
+ # Addressable 2.8.2 <a name="v2.8.2">
13
32
  - Improve cache hits and JIT friendliness ([#486](https://github.com/sporkmonger/addressable/pull/486))
14
33
  - Improve code style and test coverage ([#482](https://github.com/sporkmonger/addressable/pull/482))
15
34
  - Ensure reset of deferred validation ([#481](https://github.com/sporkmonger/addressable/pull/481))
@@ -18,7 +37,7 @@
18
37
 
19
38
  [#492]: https://github.com/sporkmonger/addressable/pull/492
20
39
 
21
- # Addressable 2.8.1
40
+ # Addressable 2.8.1 <a name="v2.8.1">
22
41
  - refactor `Addressable::URI.normalize_path` to address linter offenses ([#430](https://github.com/sporkmonger/addressable/pull/430))
23
42
  - update gemspec to reflect supported Ruby versions ([#466], [#464], [#463])
24
43
  - compatibility w/ public_suffix 5.x ([#466], [#465], [#460])
@@ -34,7 +53,7 @@
34
53
  [#465]: https://github.com/sporkmonger/addressable/pull/465
35
54
  [#466]: https://github.com/sporkmonger/addressable/pull/466
36
55
 
37
- # Addressable 2.8.0
56
+ # Addressable 2.8.0 <a name="v2.8.0">
38
57
  - fixes ReDoS vulnerability in Addressable::Template#match
39
58
  - no longer replaces `+` with spaces in queries for non-http(s) schemes
40
59
  - fixed encoding ipv6 literals
@@ -46,14 +65,14 @@
46
65
  - performance improvements
47
66
  - switch CI/CD to GitHub Actions
48
67
 
49
- # Addressable 2.7.0
68
+ # Addressable 2.7.0 <a name="v2.7.0">
50
69
  - added `:compacted` flag to `normalized_query`
51
70
  - `heuristic_parse` handles `mailto:` more intuitively
52
71
  - dropped explicit support for JRuby 9.0.5.0
53
72
  - compatibility w/ public_suffix 4.x
54
73
  - performance improvements
55
74
 
56
- # Addressable 2.6.0
75
+ # Addressable 2.6.0 <a name="v2.6.0">
57
76
  - added `tld=` method to allow assignment to the public suffix
58
77
  - most `heuristic_parse` patterns are now case-insensitive
59
78
  - `heuristic_parse` handles more `file://` URI variations
@@ -64,17 +83,17 @@
64
83
  - minor performance improvements in regexps
65
84
  - fixes to eliminate warnings
66
85
 
67
- # Addressable 2.5.2
86
+ # Addressable 2.5.2 <a name="v2.5.2">
68
87
  - better support for frozen string literals
69
88
  - fixed bug w/ uppercase characters in scheme
70
89
  - IDNA errors w/ emoji URLs
71
90
  - compatibility w/ public_suffix 3.x
72
91
 
73
- # Addressable 2.5.1
92
+ # Addressable 2.5.1 <a name="v2.5.1">
74
93
  - allow unicode normalization to be disabled for URI Template expansion
75
94
  - removed duplicate test
76
95
 
77
- # Addressable 2.5.0
96
+ # Addressable 2.5.0 <a name="v2.5.0">
78
97
  - dropping support for Ruby 1.9
79
98
  - adding support for Ruby 2.4 preview
80
99
  - add support for public suffixes and tld; first runtime dependency
@@ -88,7 +107,7 @@
88
107
  - host parts longer than 63 bytes will be ignored and not passed to libidn
89
108
  - normalized values always encoded as UTF-8
90
109
 
91
- # Addressable 2.4.0
110
+ # Addressable 2.4.0 <a name="v2.4.0">
92
111
  - support for 1.8.x dropped
93
112
  - double quotes in a host now raises an error
94
113
  - newlines in host will no longer get unescaped during normalization
@@ -100,17 +119,17 @@
100
119
  - fixed minor bug where an exception would be thrown for a missing ACE suffix
101
120
  - better partial expansion of URI templates
102
121
 
103
- # Addressable 2.3.8
122
+ # Addressable 2.3.8 <a name="v2.3.8">
104
123
  - fix warnings
105
124
  - update dependency gems
106
125
  - support for 1.8.x officially deprecated
107
126
 
108
- # Addressable 2.3.7
127
+ # Addressable 2.3.7 <a name="v2.3.7">
109
128
  - fix scenario in which invalid URIs don't get an exception until inspected
110
129
  - handle hostnames with two adjacent periods correctly
111
130
  - upgrade of RSpec
112
131
 
113
- # Addressable 2.3.6
132
+ # Addressable 2.3.6 <a name="v2.3.6">
114
133
  - normalization drops empty query string
115
134
  - better handling in template extract for missing values
116
135
  - template modifier for `'?'` now treated as optional
@@ -119,19 +138,19 @@
119
138
  - added `:sorted` option to normalization of query strings
120
139
  - fixed issue with normalization of hosts given in `'example.com.'` form
121
140
 
122
- # Addressable 2.3.5
141
+ # Addressable 2.3.5 <a name="v2.3.5">
123
142
  - added Addressable::URI#empty? method
124
143
  - Addressable::URI#hostname methods now strip square brackets from IPv6 hosts
125
144
  - compatibility with Net::HTTP in Ruby 2.0.0
126
145
  - Addressable::URI#route_from should always give relative URIs
127
146
 
128
- # Addressable 2.3.4
147
+ # Addressable 2.3.4 <a name="v2.3.4">
129
148
  - fixed issue with encoding altering its inputs
130
149
  - query string normalization now leaves ';' characters alone
131
150
  - FakeFS is detected before attempting to load unicode tables
132
151
  - additional testing to ensure frozen objects don't cause problems
133
152
 
134
- # Addressable 2.3.3
153
+ # Addressable 2.3.3 <a name="v2.3.3">
135
154
  - fixed issue with converting common primitives during template expansion
136
155
  - fixed port encoding issue
137
156
  - removed a few warnings
@@ -140,59 +159,59 @@
140
159
  - no template match should now result in nil instead of an empty MatchData
141
160
  - added license information to gemspec
142
161
 
143
- # Addressable 2.3.2
162
+ # Addressable 2.3.2 <a name="v2.3.2">
144
163
  - added Addressable::URI#default_port method
145
164
  - fixed issue with Marshalling Unicode data on Windows
146
165
  - improved heuristic parsing to better handle IPv4 addresses
147
166
 
148
- # Addressable 2.3.1
167
+ # Addressable 2.3.1 <a name="v2.3.1">
149
168
  - fixed missing unicode data file
150
169
 
151
- # Addressable 2.3.0
170
+ # Addressable 2.3.0 <a name="v2.3.0">
152
171
  - updated Addressable::Template to use RFC 6570, level 4
153
172
  - fixed compatibility problems with some versions of Ruby
154
173
  - moved unicode tables into a data file for performance reasons
155
174
  - removing support for multiple query value notations
156
175
 
157
- # Addressable 2.2.8
176
+ # Addressable 2.2.8 <a name="v2.2.8">
158
177
  - fixed issues with dot segment removal code
159
178
  - form encoding can now handle multiple values per key
160
179
  - updated development environment
161
180
 
162
- # Addressable 2.2.7
181
+ # Addressable 2.2.7 <a name="v2.2.7">
163
182
  - fixed issues related to Addressable::URI#query_values=
164
183
  - the Addressable::URI.parse method is now polymorphic
165
184
 
166
- # Addressable 2.2.6
185
+ # Addressable 2.2.6 <a name="v2.2.6">
167
186
  - changed the way ambiguous paths are handled
168
187
  - fixed bug with frozen URIs
169
188
  - https supported in heuristic parsing
170
189
 
171
- # Addressable 2.2.5
190
+ # Addressable 2.2.5 <a name="v2.2.5">
172
191
  - 'parsing' a pre-parsed URI object is now a dup operation
173
192
  - introduced conditional support for libidn
174
193
  - fixed normalization issue on ampersands in query strings
175
194
  - added additional tests around handling of query strings
176
195
 
177
- # Addressable 2.2.4
196
+ # Addressable 2.2.4 <a name="v2.2.4">
178
197
  - added origin support from draft-ietf-websec-origin-00
179
198
  - resolved issue with attempting to navigate below root
180
199
  - fixed bug with string splitting in query strings
181
200
 
182
- # Addressable 2.2.3
201
+ # Addressable 2.2.3 <a name="v2.2.3">
183
202
  - added :flat_array notation for query strings
184
203
 
185
- # Addressable 2.2.2
204
+ # Addressable 2.2.2 <a name="v2.2.2">
186
205
  - fixed issue with percent escaping of '+' character in query strings
187
206
 
188
- # Addressable 2.2.1
207
+ # Addressable 2.2.1 <a name="v2.2.1">
189
208
  - added support for application/x-www-form-urlencoded.
190
209
 
191
- # Addressable 2.2.0
210
+ # Addressable 2.2.0 <a name="v2.2.0">
192
211
  - added site methods
193
212
  - improved documentation
194
213
 
195
- # Addressable 2.1.2
214
+ # Addressable 2.1.2 <a name="v2.1.2">
196
215
  - added HTTP request URI methods
197
216
  - better handling of Windows file paths
198
217
  - validation_deferred boolean replaced with defer_validation block
@@ -200,14 +219,14 @@
200
219
  - fixed issue with constructing URIs with relative paths
201
220
  - fixed warnings
202
221
 
203
- # Addressable 2.1.1
222
+ # Addressable 2.1.1 <a name="v2.1.1">
204
223
  - more type checking changes
205
224
  - fixed issue with unicode normalization
206
225
  - added method to find template defaults
207
226
  - symbolic keys are now allowed in template mappings
208
227
  - numeric values and symbolic values are now allowed in template mappings
209
228
 
210
- # Addressable 2.1.0
229
+ # Addressable 2.1.0 <a name="v2.1.0">
211
230
  - refactored URI template support out into its own class
212
231
  - removed extract method due to being useless and unreliable
213
232
  - removed Addressable::URI.expand_template
@@ -221,15 +240,15 @@
221
240
  - worked around issue with freezing URIs
222
241
  - improved specs
223
242
 
224
- # Addressable 2.0.2
243
+ # Addressable 2.0.2 <a name="v2.0.2">
225
244
  - fixed issue with URI template expansion
226
245
  - fixed issue with percent escaping characters 0-15
227
246
 
228
- # Addressable 2.0.1
247
+ # Addressable 2.0.1 <a name="v2.0.1">
229
248
  - fixed issue with query string assignment
230
249
  - fixed issue with improperly encoded components
231
250
 
232
- # Addressable 2.0.0
251
+ # Addressable 2.0.0 <a name="v2.0.0">
233
252
  - the initialize method now takes an options hash as its only parameter
234
253
  - added query_values method to URI class
235
254
  - completely replaced IDNA implementation with pure Ruby
@@ -244,20 +263,20 @@
244
263
  - updated URI Template code to match v 03 of the draft spec
245
264
  - added a bunch of new specifications
246
265
 
247
- # Addressable 1.0.4
266
+ # Addressable 1.0.4 <a name="v1.0.4">
248
267
  - switched to using RSpec's pending system for specs that rely on IDN
249
268
  - fixed issue with creating URIs with paths that are not prefixed with '/'
250
269
 
251
- # Addressable 1.0.3
270
+ # Addressable 1.0.3 <a name="v1.0.3">
252
271
  - implemented a hash method
253
272
 
254
- # Addressable 1.0.2
273
+ # Addressable 1.0.2 <a name="v1.0.2">
255
274
  - fixed minor bug with the extract_mapping method
256
275
 
257
- # Addressable 1.0.1
276
+ # Addressable 1.0.1 <a name="v1.0.1">
258
277
  - fixed minor bug with the extract_mapping method
259
278
 
260
- # Addressable 1.0.0
279
+ # Addressable 1.0.0 <a name="v1.0.0">
261
280
  - heuristic parse method added
262
281
  - parsing is slightly more strict
263
282
  - replaced to_h with to_hash
@@ -266,16 +285,16 @@
266
285
  - improved heckle rake task
267
286
  - no surviving heckle mutations
268
287
 
269
- # Addressable 0.1.2
288
+ # Addressable 0.1.2 <a name="v0.1.2">
270
289
  - improved normalization
271
290
  - fixed bug in joining algorithm
272
291
  - updated specifications
273
292
 
274
- # Addressable 0.1.1
293
+ # Addressable 0.1.1 <a name="v0.1.1">
275
294
  - updated documentation
276
295
  - added URI Template variable extraction
277
296
 
278
- # Addressable 0.1.0
297
+ # Addressable 0.1.0 <a name="v0.1.0">
279
298
  - initial release
280
299
  - implementation based on RFC 3986, 3987
281
300
  - support for IRIs via libidn
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :test do
8
+ gem 'bigdecimal' if RUBY_VERSION > '2.4'
8
9
  gem 'rspec', '~> 3.8'
9
10
  gem 'rspec-its', '~> 1.3'
10
11
  end
data/Rakefile CHANGED
@@ -20,16 +20,18 @@ additionally provides extensive support for IRIs and URI templates.
20
20
  TEXT
21
21
 
22
22
  PKG_FILES = FileList[
23
- "lib/**/*", "spec/**/*", "vendor/**/*", "data/**/*",
24
- "tasks/**/*",
25
- "[A-Z]*", "Rakefile"
26
- ].exclude(/pkg/).exclude(/database\.yml/).
27
- exclude(/Gemfile\.lock/).exclude(/[_\.]git$/).
28
- exclude(/coverage/)
23
+ "data/**/*",
24
+ "lib/**/*.rb",
25
+ "spec/**/*.rb",
26
+ "tasks/**/*.rake",
27
+ "addressable.gemspec",
28
+ "CHANGELOG.md",
29
+ "Gemfile",
30
+ "LICENSE.txt",
31
+ "README.md",
32
+ "Rakefile",
33
+ ]
29
34
 
30
35
  task :default => "spec"
31
36
 
32
- WINDOWS = (RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/) rescue false
33
- SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
34
-
35
37
  Dir['tasks/**/*.rake'].each { |rake| load rake }
data/addressable.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: addressable 2.8.4 ruby lib
2
+ # stub: addressable 2.8.7 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "addressable".freeze
6
- s.version = "2.8.4"
6
+ s.version = "2.8.7".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
- s.metadata = { "changelog_uri" => "https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md" } if s.respond_to? :metadata=
9
+ s.metadata = { "changelog_uri" => "https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md#v2.8.7" } if s.respond_to? :metadata=
10
10
  s.require_paths = ["lib".freeze]
11
11
  s.authors = ["Bob Aman".freeze]
12
- s.date = "2023-04-09"
12
+ s.date = "2024-06-21"
13
13
  s.description = "Addressable is an alternative implementation to the URI implementation that is\npart of Ruby's standard library. It is flexible, offers heuristic parsing, and\nadditionally provides extensive support for IRIs and URI templates.\n".freeze
14
14
  s.email = "bob@sporkmonger.com".freeze
15
15
  s.extra_rdoc_files = ["README.md".freeze]
@@ -18,11 +18,11 @@ Gem::Specification.new do |s|
18
18
  s.licenses = ["Apache-2.0".freeze]
19
19
  s.rdoc_options = ["--main".freeze, "README.md".freeze]
20
20
  s.required_ruby_version = Gem::Requirement.new(">= 2.2".freeze)
21
- s.rubygems_version = "3.4.10".freeze
21
+ s.rubygems_version = "3.5.11".freeze
22
22
  s.summary = "URI Implementation".freeze
23
23
 
24
24
  s.specification_version = 4
25
25
 
26
- s.add_runtime_dependency(%q<public_suffix>.freeze, [">= 2.0.2", "< 6.0"])
27
- s.add_development_dependency(%q<bundler>.freeze, [">= 1.0", "< 3.0"])
26
+ s.add_runtime_dependency(%q<public_suffix>.freeze, [">= 2.0.2".freeze, "< 7.0".freeze])
27
+ s.add_development_dependency(%q<bundler>.freeze, [">= 1.0".freeze, "< 3.0".freeze])
28
28
  end
@@ -157,7 +157,7 @@ module Addressable
157
157
  # the ::MatchData#[] behavior.
158
158
  #
159
159
  # @param [#to_int, nil] len
160
- # If provided, an array of values will be returend with the given
160
+ # If provided, an array of values will be returned with the given
161
161
  # parameter used as length.
162
162
  #
163
163
  # @return [Array, String, nil]
@@ -50,6 +50,7 @@ module Addressable
50
50
  SUB_DELIMS = "\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\="
51
51
  RESERVED = (GEN_DELIMS + SUB_DELIMS).freeze
52
52
  UNRESERVED = (ALPHA + DIGIT + "\\-\\.\\_\\~").freeze
53
+ RESERVED_AND_UNRESERVED = RESERVED + UNRESERVED
53
54
  PCHAR = (UNRESERVED + SUB_DELIMS + "\\:\\@").freeze
54
55
  SCHEME = (ALPHA + DIGIT + "\\-\\+\\.").freeze
55
56
  HOST = (UNRESERVED + SUB_DELIMS + "\\[\\:\\]").freeze
@@ -68,6 +69,18 @@ module Addressable
68
69
  QUERY = %r{[^a-zA-Z0-9\-\.\_\~\!\$\'\(\)\*\+\,\=\:\@\/\?%]|%(?!2B|2b)}
69
70
  end
70
71
 
72
+ module CharacterClassesRegexps
73
+ AUTHORITY = /[^#{CharacterClasses::AUTHORITY}]/
74
+ FRAGMENT = /[^#{CharacterClasses::FRAGMENT}]/
75
+ HOST = /[^#{CharacterClasses::HOST}]/
76
+ PATH = /[^#{CharacterClasses::PATH}]/
77
+ QUERY = /[^#{CharacterClasses::QUERY}]/
78
+ RESERVED = /[^#{CharacterClasses::RESERVED}]/
79
+ RESERVED_AND_UNRESERVED = /[^#{CharacterClasses::RESERVED_AND_UNRESERVED}]/
80
+ SCHEME = /[^#{CharacterClasses::SCHEME}]/
81
+ UNRESERVED = /[^#{CharacterClasses::UNRESERVED}]/
82
+ end
83
+
71
84
  SLASH = '/'
72
85
  EMPTY_STR = ''
73
86
 
@@ -344,17 +357,13 @@ module Addressable
344
357
  ##
345
358
  # Tables used to optimize encoding operations in `self.encode_component`
346
359
  # and `self.normalize_component`
347
- SEQUENCE_ENCODING_TABLE = Hash.new do |hash, sequence|
348
- hash[sequence] = sequence.unpack("C*").map do |c|
349
- format("%02x", c)
350
- end.join
351
- end
360
+ SEQUENCE_ENCODING_TABLE = (0..255).map do |byte|
361
+ format("%02x", byte).freeze
362
+ end.freeze
352
363
 
353
- SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE = Hash.new do |hash, sequence|
354
- hash[sequence] = sequence.unpack("C*").map do |c|
355
- format("%%%02X", c)
356
- end.join
357
- end
364
+ SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE = (0..255).map do |byte|
365
+ format("%%%02X", byte).freeze
366
+ end.freeze
358
367
 
359
368
  ##
360
369
  # Percent encodes a URI component.
@@ -391,9 +400,7 @@ module Addressable
391
400
  # "simple/example", Addressable::URI::CharacterClasses::UNRESERVED
392
401
  # )
393
402
  # => "simple%2Fexample"
394
- def self.encode_component(component, character_class=
395
- CharacterClasses::RESERVED + CharacterClasses::UNRESERVED,
396
- upcase_encoded='')
403
+ def self.encode_component(component, character_class=CharacterClassesRegexps::RESERVED_AND_UNRESERVED, upcase_encoded='')
397
404
  return nil if component.nil?
398
405
 
399
406
  begin
@@ -421,16 +428,17 @@ module Addressable
421
428
  component = component.dup
422
429
  component.force_encoding(Encoding::ASCII_8BIT)
423
430
  # Avoiding gsub! because there are edge cases with frozen strings
424
- component = component.gsub(character_class) do |sequence|
425
- SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE[sequence]
431
+ component = component.gsub(character_class) do |char|
432
+ SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE[char.ord]
426
433
  end
427
434
  if upcase_encoded.length > 0
428
- upcase_encoded_chars = upcase_encoded.chars.map do |char|
429
- SEQUENCE_ENCODING_TABLE[char]
435
+ upcase_encoded_chars = upcase_encoded.bytes.map do |byte|
436
+ SEQUENCE_ENCODING_TABLE[byte]
430
437
  end
431
438
  component = component.gsub(/%(#{upcase_encoded_chars.join('|')})/,
432
439
  &:upcase)
433
440
  end
441
+
434
442
  return component
435
443
  end
436
444
 
@@ -542,7 +550,7 @@ module Addressable
542
550
  # )
543
551
  # => "one two%2Fthree&four"
544
552
  def self.normalize_component(component, character_class=
545
- CharacterClasses::RESERVED + CharacterClasses::UNRESERVED,
553
+ CharacterClassesRegexps::RESERVED_AND_UNRESERVED,
546
554
  leave_encoded='')
547
555
  return nil if component.nil?
548
556
 
@@ -560,10 +568,9 @@ module Addressable
560
568
  leave_re = if leave_encoded.length > 0
561
569
  character_class = "#{character_class}%" unless character_class.include?('%')
562
570
 
563
- "|%(?!#{leave_encoded.chars.flat_map do |char|
564
- seq = SEQUENCE_ENCODING_TABLE[char]
565
- [seq.upcase, seq.downcase]
566
- end.join('|')})"
571
+ bytes = leave_encoded.bytes
572
+ leave_encoded_pattern = bytes.map { |b| SEQUENCE_ENCODING_TABLE[b] }.join('|')
573
+ "|%(?!#{leave_encoded_pattern}|#{leave_encoded_pattern.upcase})"
567
574
  end
568
575
 
569
576
  character_class = if leave_re
@@ -623,15 +630,15 @@ module Addressable
623
630
  uri_object = uri.kind_of?(self) ? uri : self.parse(uri)
624
631
  encoded_uri = Addressable::URI.new(
625
632
  :scheme => self.encode_component(uri_object.scheme,
626
- Addressable::URI::CharacterClasses::SCHEME),
633
+ Addressable::URI::CharacterClassesRegexps::SCHEME),
627
634
  :authority => self.encode_component(uri_object.authority,
628
- Addressable::URI::CharacterClasses::AUTHORITY),
635
+ Addressable::URI::CharacterClassesRegexps::AUTHORITY),
629
636
  :path => self.encode_component(uri_object.path,
630
- Addressable::URI::CharacterClasses::PATH),
637
+ Addressable::URI::CharacterClassesRegexps::PATH),
631
638
  :query => self.encode_component(uri_object.query,
632
- Addressable::URI::CharacterClasses::QUERY),
639
+ Addressable::URI::CharacterClassesRegexps::QUERY),
633
640
  :fragment => self.encode_component(uri_object.fragment,
634
- Addressable::URI::CharacterClasses::FRAGMENT)
641
+ Addressable::URI::CharacterClassesRegexps::FRAGMENT)
635
642
  )
636
643
  if return_type == String
637
644
  return encoded_uri.to_s
@@ -696,19 +703,19 @@ module Addressable
696
703
  end
697
704
  encoded_uri = Addressable::URI.new(
698
705
  :scheme => self.encode_component(components[:scheme],
699
- Addressable::URI::CharacterClasses::SCHEME),
706
+ Addressable::URI::CharacterClassesRegexps::SCHEME),
700
707
  :user => self.encode_component(components[:user],
701
- Addressable::URI::CharacterClasses::UNRESERVED),
708
+ Addressable::URI::CharacterClassesRegexps::UNRESERVED),
702
709
  :password => self.encode_component(components[:password],
703
- Addressable::URI::CharacterClasses::UNRESERVED),
710
+ Addressable::URI::CharacterClassesRegexps::UNRESERVED),
704
711
  :host => components[:host],
705
712
  :port => components[:port],
706
713
  :path => self.encode_component(components[:path],
707
- Addressable::URI::CharacterClasses::PATH),
714
+ Addressable::URI::CharacterClassesRegexps::PATH),
708
715
  :query => self.encode_component(components[:query],
709
- Addressable::URI::CharacterClasses::QUERY),
716
+ Addressable::URI::CharacterClassesRegexps::QUERY),
710
717
  :fragment => self.encode_component(components[:fragment],
711
- Addressable::URI::CharacterClasses::FRAGMENT)
718
+ Addressable::URI::CharacterClassesRegexps::FRAGMENT)
712
719
  )
713
720
  if return_type == String
714
721
  return encoded_uri.to_s
@@ -759,11 +766,11 @@ module Addressable
759
766
  [
760
767
  self.encode_component(
761
768
  key.gsub(/(\r\n|\n|\r)/, "\r\n"),
762
- CharacterClasses::UNRESERVED
769
+ CharacterClassesRegexps::UNRESERVED
763
770
  ).gsub("%20", "+"),
764
771
  self.encode_component(
765
772
  value.gsub(/(\r\n|\n|\r)/, "\r\n"),
766
- CharacterClasses::UNRESERVED
773
+ CharacterClassesRegexps::UNRESERVED
767
774
  ).gsub("%20", "+")
768
775
  ]
769
776
  end
@@ -1532,7 +1539,7 @@ module Addressable
1532
1539
  # Relative paths with colons in the first segment are ambiguous.
1533
1540
  path = path.sub(":", "%2F")
1534
1541
  end
1535
- # String#split(delimeter, -1) uses the more strict splitting behavior
1542
+ # String#split(delimiter, -1) uses the more strict splitting behavior
1536
1543
  # found by default in Python.
1537
1544
  result = path.strip.split(SLASH, -1).map do |segment|
1538
1545
  Addressable::URI.normalize_component(
@@ -1738,20 +1745,20 @@ module Addressable
1738
1745
  buffer = "".dup
1739
1746
  new_query_values.each do |key, value|
1740
1747
  encoded_key = URI.encode_component(
1741
- key, CharacterClasses::UNRESERVED
1748
+ key, CharacterClassesRegexps::UNRESERVED
1742
1749
  )
1743
1750
  if value == nil
1744
1751
  buffer << "#{encoded_key}&"
1745
1752
  elsif value.kind_of?(Array)
1746
1753
  value.each do |sub_value|
1747
1754
  encoded_value = URI.encode_component(
1748
- sub_value, CharacterClasses::UNRESERVED
1755
+ sub_value, CharacterClassesRegexps::UNRESERVED
1749
1756
  )
1750
1757
  buffer << "#{encoded_key}=#{encoded_value}&"
1751
1758
  end
1752
1759
  else
1753
1760
  encoded_value = URI.encode_component(
1754
- value, CharacterClasses::UNRESERVED
1761
+ value, CharacterClassesRegexps::UNRESERVED
1755
1762
  )
1756
1763
  buffer << "#{encoded_key}=#{encoded_value}&"
1757
1764
  end
@@ -2396,6 +2403,25 @@ module Addressable
2396
2403
  @validation_deferred = false
2397
2404
  end
2398
2405
 
2406
+ def encode_with(coder)
2407
+ instance_variables.each do |ivar|
2408
+ value = instance_variable_get(ivar)
2409
+ if value != NONE
2410
+ key = ivar.to_s.slice(1..-1)
2411
+ coder[key] = value
2412
+ end
2413
+ end
2414
+ nil
2415
+ end
2416
+
2417
+ def init_with(coder)
2418
+ reset_ivs
2419
+ coder.map.each do |key, value|
2420
+ instance_variable_set("@#{key}", value)
2421
+ end
2422
+ nil
2423
+ end
2424
+
2399
2425
  protected
2400
2426
  SELF_REF = '.'
2401
2427
  PARENT = '..'
@@ -2569,7 +2595,7 @@ module Addressable
2569
2595
  @query = nil
2570
2596
  end
2571
2597
 
2572
- NONE = Object.new.freeze
2598
+ NONE = Module.new.freeze
2573
2599
 
2574
2600
  private_constant :NONE
2575
2601
  end
@@ -23,7 +23,7 @@ if !defined?(Addressable::VERSION)
23
23
  module VERSION
24
24
  MAJOR = 2
25
25
  MINOR = 8
26
- TINY = 4
26
+ TINY = 7
27
27
 
28
28
  STRING = [MAJOR, MINOR, TINY].join('.')
29
29
  end
@@ -20,6 +20,7 @@ require "spec_helper"
20
20
  require "addressable/uri"
21
21
  require "uri"
22
22
  require "ipaddr"
23
+ require "yaml"
23
24
 
24
25
  if !"".respond_to?("force_encoding")
25
26
  class String
@@ -6768,6 +6769,37 @@ describe Addressable::URI, "when initializing a subclass of Addressable::URI" do
6768
6769
  end
6769
6770
  end
6770
6771
 
6772
+ describe Addressable::URI, "support serialization roundtrip" do
6773
+ before do
6774
+ @uri = Addressable::URI.new(
6775
+ :scheme => "http",
6776
+ :user => "user",
6777
+ :password => "password",
6778
+ :host => "example.com",
6779
+ :port => 80,
6780
+ :path => "/path",
6781
+ :query => "query=value",
6782
+ :fragment => "fragment"
6783
+ )
6784
+ end
6785
+
6786
+ it "is in a working state after being serialized with Marshal" do
6787
+ @uri = Addressable::URI.parse("http://example.com")
6788
+ cloned_uri = Marshal.load(Marshal.dump(@uri))
6789
+ expect(cloned_uri.normalized_scheme).to be == @uri.normalized_scheme
6790
+ end
6791
+
6792
+ it "is in a working state after being serialized with YAML" do
6793
+ @uri = Addressable::URI.parse("http://example.com")
6794
+ cloned_uri = if YAML.respond_to?(:unsafe_load)
6795
+ YAML.unsafe_load(YAML.dump(@uri))
6796
+ else
6797
+ YAML.load(YAML.dump(@uri))
6798
+ end
6799
+ expect(cloned_uri.normalized_scheme).to be == @uri.normalized_scheme
6800
+ end
6801
+ end
6802
+
6771
6803
  describe Addressable::URI, "when initialized in a non-main `Ractor`" do
6772
6804
  it "should have the same value as if used in the main `Ractor`" do
6773
6805
  pending("Ruby 3.0+ for `Ractor` support") unless defined?(Ractor)
@@ -6799,3 +6831,10 @@ describe Addressable::URI, "when deferring validation" do
6799
6831
  expect(res).to be nil
6800
6832
  end
6801
6833
  end
6834
+
6835
+ describe Addressable::URI, "YAML safe loading" do
6836
+ it "doesn't serialize anonymous objects" do
6837
+ url = Addressable::URI.parse("http://example.com/")
6838
+ expect(YAML.dump(url)).to_not include("!ruby/object {}")
6839
+ end
6840
+ end
data/tasks/gem.rake CHANGED
@@ -21,7 +21,7 @@ namespace :gem do
21
21
 
22
22
  s.required_ruby_version = ">= 2.2"
23
23
 
24
- s.add_runtime_dependency "public_suffix", ">= 2.0.2", "< 6.0"
24
+ s.add_runtime_dependency "public_suffix", ">= 2.0.2", "< 7.0"
25
25
  s.add_development_dependency "bundler", ">= 1.0", "< 3.0"
26
26
 
27
27
  s.require_path = "lib"
@@ -31,7 +31,7 @@ namespace :gem do
31
31
  s.homepage = "https://github.com/sporkmonger/addressable"
32
32
  s.license = "Apache-2.0"
33
33
  s.metadata = {
34
- "changelog_uri" => "https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md"
34
+ "changelog_uri" => "https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md#v#{PKG_VERSION}"
35
35
  }
36
36
  end
37
37
 
@@ -56,7 +56,7 @@ namespace :gem do
56
56
 
57
57
  desc "Install the gem"
58
58
  task :install => ["clobber", "gem:package"] do
59
- sh "#{SUDO} gem install --local pkg/#{GEM_SPEC.full_name}"
59
+ sh "gem install --local ./pkg/#{GEM_SPEC.full_name}.gem"
60
60
  end
61
61
 
62
62
  desc "Uninstall the gem"
@@ -65,7 +65,7 @@ namespace :gem do
65
65
  if installed_list &&
66
66
  (installed_list.collect { |s| s.version.to_s}.include?(PKG_VERSION))
67
67
  sh(
68
- "#{SUDO} gem uninstall --version '#{PKG_VERSION}' " +
68
+ "gem uninstall --version '#{PKG_VERSION}' " +
69
69
  "--ignore-dependencies --executables #{PKG_NAME}"
70
70
  )
71
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addressable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.4
4
+ version: 2.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Aman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-09 00:00:00.000000000 Z
11
+ date: 2024-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: public_suffix
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 2.0.2
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.0'
22
+ version: '7.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 2.0.2
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.0'
32
+ version: '7.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -91,8 +91,8 @@ homepage: https://github.com/sporkmonger/addressable
91
91
  licenses:
92
92
  - Apache-2.0
93
93
  metadata:
94
- changelog_uri: https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md
95
- post_install_message:
94
+ changelog_uri: https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md#v2.8.7
95
+ post_install_message:
96
96
  rdoc_options:
97
97
  - "--main"
98
98
  - README.md
@@ -109,8 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 3.4.10
113
- signing_key:
112
+ rubygems_version: 3.5.11
113
+ signing_key:
114
114
  specification_version: 4
115
115
  summary: URI Implementation
116
116
  test_files: []