addressable 2.8.4 → 2.8.6
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 +4 -4
- data/CHANGELOG.md +57 -43
- data/Rakefile +11 -6
- data/addressable.gemspec +7 -7
- data/lib/addressable/uri.rb +65 -39
- data/lib/addressable/version.rb +1 -1
- data/spec/addressable/uri_spec.rb +39 -0
- data/tasks/gem.rake +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4023555b4bb6c374726bb9647a29d30943c637115619670a09632fe7a4e28765
|
|
4
|
+
data.tar.gz: 95ad31a9e1dd01f2bc9a7c097eb452f07ed52be16dcd2ad4946652648dd7808c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7dd6eed173bc4a06a3abb74f6fdbf501ee12b3fcb2828c0f21db98d1779175bce4dc900999269db24cc8647c3148b06cf1d9c768c97c7591a48f1e43751bb7b
|
|
7
|
+
data.tar.gz: 3bbe976f23a4c3a6776a44d6ff2147b9ab87418162af57b2f278089528416eb3d564b114f96f165946d9126ee68d5da86c0ac01a9e2fa2792547bb312f40f046
|
data/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
# Addressable 2.8.
|
|
1
|
+
# Addressable 2.8.6 <a name="v2.8.6">
|
|
2
|
+
- Memoize regexps for common character classes ([#524])
|
|
3
|
+
|
|
4
|
+
[#524]: https://github.com/sporkmonger/addressable/pull/524
|
|
5
|
+
|
|
6
|
+
# Addressable 2.8.5 <a name="v2.8.5">
|
|
7
|
+
- Fix thread safety issue with encoding tables ([#515])
|
|
8
|
+
- Define URI::NONE as a module to avoid serialization issues ([#509])
|
|
9
|
+
- Fix YAML serialization ([#508])
|
|
10
|
+
|
|
11
|
+
[#508]: https://github.com/sporkmonger/addressable/pull/508
|
|
12
|
+
[#509]: https://github.com/sporkmonger/addressable/pull/509
|
|
13
|
+
[#515]: https://github.com/sporkmonger/addressable/pull/515
|
|
14
|
+
|
|
15
|
+
# Addressable 2.8.4 <a name="v2.8.4">
|
|
2
16
|
- Restore `Addressable::IDNA.unicode_normalize_kc` as a deprecated method ([#504])
|
|
3
17
|
|
|
4
18
|
[#504]: https://github.com/sporkmonger/addressable/pull/504
|
|
5
19
|
|
|
6
|
-
# Addressable 2.8.3
|
|
20
|
+
# Addressable 2.8.3 <a name="v2.8.3">
|
|
7
21
|
- Fix template expand level 2 hash support for non-string objects ([#499], [#498])
|
|
8
22
|
|
|
9
23
|
[#499]: https://github.com/sporkmonger/addressable/pull/499
|
|
10
24
|
[#498]: https://github.com/sporkmonger/addressable/pull/498
|
|
11
25
|
|
|
12
|
-
# Addressable 2.8.2
|
|
26
|
+
# Addressable 2.8.2 <a name="v2.8.2">
|
|
13
27
|
- Improve cache hits and JIT friendliness ([#486](https://github.com/sporkmonger/addressable/pull/486))
|
|
14
28
|
- Improve code style and test coverage ([#482](https://github.com/sporkmonger/addressable/pull/482))
|
|
15
29
|
- Ensure reset of deferred validation ([#481](https://github.com/sporkmonger/addressable/pull/481))
|
|
@@ -18,7 +32,7 @@
|
|
|
18
32
|
|
|
19
33
|
[#492]: https://github.com/sporkmonger/addressable/pull/492
|
|
20
34
|
|
|
21
|
-
# Addressable 2.8.1
|
|
35
|
+
# Addressable 2.8.1 <a name="v2.8.1">
|
|
22
36
|
- refactor `Addressable::URI.normalize_path` to address linter offenses ([#430](https://github.com/sporkmonger/addressable/pull/430))
|
|
23
37
|
- update gemspec to reflect supported Ruby versions ([#466], [#464], [#463])
|
|
24
38
|
- compatibility w/ public_suffix 5.x ([#466], [#465], [#460])
|
|
@@ -34,7 +48,7 @@
|
|
|
34
48
|
[#465]: https://github.com/sporkmonger/addressable/pull/465
|
|
35
49
|
[#466]: https://github.com/sporkmonger/addressable/pull/466
|
|
36
50
|
|
|
37
|
-
# Addressable 2.8.0
|
|
51
|
+
# Addressable 2.8.0 <a name="v2.8.0">
|
|
38
52
|
- fixes ReDoS vulnerability in Addressable::Template#match
|
|
39
53
|
- no longer replaces `+` with spaces in queries for non-http(s) schemes
|
|
40
54
|
- fixed encoding ipv6 literals
|
|
@@ -46,14 +60,14 @@
|
|
|
46
60
|
- performance improvements
|
|
47
61
|
- switch CI/CD to GitHub Actions
|
|
48
62
|
|
|
49
|
-
# Addressable 2.7.0
|
|
63
|
+
# Addressable 2.7.0 <a name="v2.7.0">
|
|
50
64
|
- added `:compacted` flag to `normalized_query`
|
|
51
65
|
- `heuristic_parse` handles `mailto:` more intuitively
|
|
52
66
|
- dropped explicit support for JRuby 9.0.5.0
|
|
53
67
|
- compatibility w/ public_suffix 4.x
|
|
54
68
|
- performance improvements
|
|
55
69
|
|
|
56
|
-
# Addressable 2.6.0
|
|
70
|
+
# Addressable 2.6.0 <a name="v2.6.0">
|
|
57
71
|
- added `tld=` method to allow assignment to the public suffix
|
|
58
72
|
- most `heuristic_parse` patterns are now case-insensitive
|
|
59
73
|
- `heuristic_parse` handles more `file://` URI variations
|
|
@@ -64,17 +78,17 @@
|
|
|
64
78
|
- minor performance improvements in regexps
|
|
65
79
|
- fixes to eliminate warnings
|
|
66
80
|
|
|
67
|
-
# Addressable 2.5.2
|
|
81
|
+
# Addressable 2.5.2 <a name="v2.5.2">
|
|
68
82
|
- better support for frozen string literals
|
|
69
83
|
- fixed bug w/ uppercase characters in scheme
|
|
70
84
|
- IDNA errors w/ emoji URLs
|
|
71
85
|
- compatibility w/ public_suffix 3.x
|
|
72
86
|
|
|
73
|
-
# Addressable 2.5.1
|
|
87
|
+
# Addressable 2.5.1 <a name="v2.5.1">
|
|
74
88
|
- allow unicode normalization to be disabled for URI Template expansion
|
|
75
89
|
- removed duplicate test
|
|
76
90
|
|
|
77
|
-
# Addressable 2.5.0
|
|
91
|
+
# Addressable 2.5.0 <a name="v2.5.0">
|
|
78
92
|
- dropping support for Ruby 1.9
|
|
79
93
|
- adding support for Ruby 2.4 preview
|
|
80
94
|
- add support for public suffixes and tld; first runtime dependency
|
|
@@ -88,7 +102,7 @@
|
|
|
88
102
|
- host parts longer than 63 bytes will be ignored and not passed to libidn
|
|
89
103
|
- normalized values always encoded as UTF-8
|
|
90
104
|
|
|
91
|
-
# Addressable 2.4.0
|
|
105
|
+
# Addressable 2.4.0 <a name="v2.4.0">
|
|
92
106
|
- support for 1.8.x dropped
|
|
93
107
|
- double quotes in a host now raises an error
|
|
94
108
|
- newlines in host will no longer get unescaped during normalization
|
|
@@ -100,17 +114,17 @@
|
|
|
100
114
|
- fixed minor bug where an exception would be thrown for a missing ACE suffix
|
|
101
115
|
- better partial expansion of URI templates
|
|
102
116
|
|
|
103
|
-
# Addressable 2.3.8
|
|
117
|
+
# Addressable 2.3.8 <a name="v2.3.8">
|
|
104
118
|
- fix warnings
|
|
105
119
|
- update dependency gems
|
|
106
120
|
- support for 1.8.x officially deprecated
|
|
107
121
|
|
|
108
|
-
# Addressable 2.3.7
|
|
122
|
+
# Addressable 2.3.7 <a name="v2.3.7">
|
|
109
123
|
- fix scenario in which invalid URIs don't get an exception until inspected
|
|
110
124
|
- handle hostnames with two adjacent periods correctly
|
|
111
125
|
- upgrade of RSpec
|
|
112
126
|
|
|
113
|
-
# Addressable 2.3.6
|
|
127
|
+
# Addressable 2.3.6 <a name="v2.3.6">
|
|
114
128
|
- normalization drops empty query string
|
|
115
129
|
- better handling in template extract for missing values
|
|
116
130
|
- template modifier for `'?'` now treated as optional
|
|
@@ -119,19 +133,19 @@
|
|
|
119
133
|
- added `:sorted` option to normalization of query strings
|
|
120
134
|
- fixed issue with normalization of hosts given in `'example.com.'` form
|
|
121
135
|
|
|
122
|
-
# Addressable 2.3.5
|
|
136
|
+
# Addressable 2.3.5 <a name="v2.3.5">
|
|
123
137
|
- added Addressable::URI#empty? method
|
|
124
138
|
- Addressable::URI#hostname methods now strip square brackets from IPv6 hosts
|
|
125
139
|
- compatibility with Net::HTTP in Ruby 2.0.0
|
|
126
140
|
- Addressable::URI#route_from should always give relative URIs
|
|
127
141
|
|
|
128
|
-
# Addressable 2.3.4
|
|
142
|
+
# Addressable 2.3.4 <a name="v2.3.4">
|
|
129
143
|
- fixed issue with encoding altering its inputs
|
|
130
144
|
- query string normalization now leaves ';' characters alone
|
|
131
145
|
- FakeFS is detected before attempting to load unicode tables
|
|
132
146
|
- additional testing to ensure frozen objects don't cause problems
|
|
133
147
|
|
|
134
|
-
# Addressable 2.3.3
|
|
148
|
+
# Addressable 2.3.3 <a name="v2.3.3">
|
|
135
149
|
- fixed issue with converting common primitives during template expansion
|
|
136
150
|
- fixed port encoding issue
|
|
137
151
|
- removed a few warnings
|
|
@@ -140,59 +154,59 @@
|
|
|
140
154
|
- no template match should now result in nil instead of an empty MatchData
|
|
141
155
|
- added license information to gemspec
|
|
142
156
|
|
|
143
|
-
# Addressable 2.3.2
|
|
157
|
+
# Addressable 2.3.2 <a name="v2.3.2">
|
|
144
158
|
- added Addressable::URI#default_port method
|
|
145
159
|
- fixed issue with Marshalling Unicode data on Windows
|
|
146
160
|
- improved heuristic parsing to better handle IPv4 addresses
|
|
147
161
|
|
|
148
|
-
# Addressable 2.3.1
|
|
162
|
+
# Addressable 2.3.1 <a name="v2.3.1">
|
|
149
163
|
- fixed missing unicode data file
|
|
150
164
|
|
|
151
|
-
# Addressable 2.3.0
|
|
165
|
+
# Addressable 2.3.0 <a name="v2.3.0">
|
|
152
166
|
- updated Addressable::Template to use RFC 6570, level 4
|
|
153
167
|
- fixed compatibility problems with some versions of Ruby
|
|
154
168
|
- moved unicode tables into a data file for performance reasons
|
|
155
169
|
- removing support for multiple query value notations
|
|
156
170
|
|
|
157
|
-
# Addressable 2.2.8
|
|
171
|
+
# Addressable 2.2.8 <a name="v2.2.8">
|
|
158
172
|
- fixed issues with dot segment removal code
|
|
159
173
|
- form encoding can now handle multiple values per key
|
|
160
174
|
- updated development environment
|
|
161
175
|
|
|
162
|
-
# Addressable 2.2.7
|
|
176
|
+
# Addressable 2.2.7 <a name="v2.2.7">
|
|
163
177
|
- fixed issues related to Addressable::URI#query_values=
|
|
164
178
|
- the Addressable::URI.parse method is now polymorphic
|
|
165
179
|
|
|
166
|
-
# Addressable 2.2.6
|
|
180
|
+
# Addressable 2.2.6 <a name="v2.2.6">
|
|
167
181
|
- changed the way ambiguous paths are handled
|
|
168
182
|
- fixed bug with frozen URIs
|
|
169
183
|
- https supported in heuristic parsing
|
|
170
184
|
|
|
171
|
-
# Addressable 2.2.5
|
|
185
|
+
# Addressable 2.2.5 <a name="v2.2.5">
|
|
172
186
|
- 'parsing' a pre-parsed URI object is now a dup operation
|
|
173
187
|
- introduced conditional support for libidn
|
|
174
188
|
- fixed normalization issue on ampersands in query strings
|
|
175
189
|
- added additional tests around handling of query strings
|
|
176
190
|
|
|
177
|
-
# Addressable 2.2.4
|
|
191
|
+
# Addressable 2.2.4 <a name="v2.2.4">
|
|
178
192
|
- added origin support from draft-ietf-websec-origin-00
|
|
179
193
|
- resolved issue with attempting to navigate below root
|
|
180
194
|
- fixed bug with string splitting in query strings
|
|
181
195
|
|
|
182
|
-
# Addressable 2.2.3
|
|
196
|
+
# Addressable 2.2.3 <a name="v2.2.3">
|
|
183
197
|
- added :flat_array notation for query strings
|
|
184
198
|
|
|
185
|
-
# Addressable 2.2.2
|
|
199
|
+
# Addressable 2.2.2 <a name="v2.2.2">
|
|
186
200
|
- fixed issue with percent escaping of '+' character in query strings
|
|
187
201
|
|
|
188
|
-
# Addressable 2.2.1
|
|
202
|
+
# Addressable 2.2.1 <a name="v2.2.1">
|
|
189
203
|
- added support for application/x-www-form-urlencoded.
|
|
190
204
|
|
|
191
|
-
# Addressable 2.2.0
|
|
205
|
+
# Addressable 2.2.0 <a name="v2.2.0">
|
|
192
206
|
- added site methods
|
|
193
207
|
- improved documentation
|
|
194
208
|
|
|
195
|
-
# Addressable 2.1.2
|
|
209
|
+
# Addressable 2.1.2 <a name="v2.1.2">
|
|
196
210
|
- added HTTP request URI methods
|
|
197
211
|
- better handling of Windows file paths
|
|
198
212
|
- validation_deferred boolean replaced with defer_validation block
|
|
@@ -200,14 +214,14 @@
|
|
|
200
214
|
- fixed issue with constructing URIs with relative paths
|
|
201
215
|
- fixed warnings
|
|
202
216
|
|
|
203
|
-
# Addressable 2.1.1
|
|
217
|
+
# Addressable 2.1.1 <a name="v2.1.1">
|
|
204
218
|
- more type checking changes
|
|
205
219
|
- fixed issue with unicode normalization
|
|
206
220
|
- added method to find template defaults
|
|
207
221
|
- symbolic keys are now allowed in template mappings
|
|
208
222
|
- numeric values and symbolic values are now allowed in template mappings
|
|
209
223
|
|
|
210
|
-
# Addressable 2.1.0
|
|
224
|
+
# Addressable 2.1.0 <a name="v2.1.0">
|
|
211
225
|
- refactored URI template support out into its own class
|
|
212
226
|
- removed extract method due to being useless and unreliable
|
|
213
227
|
- removed Addressable::URI.expand_template
|
|
@@ -221,15 +235,15 @@
|
|
|
221
235
|
- worked around issue with freezing URIs
|
|
222
236
|
- improved specs
|
|
223
237
|
|
|
224
|
-
# Addressable 2.0.2
|
|
238
|
+
# Addressable 2.0.2 <a name="v2.0.2">
|
|
225
239
|
- fixed issue with URI template expansion
|
|
226
240
|
- fixed issue with percent escaping characters 0-15
|
|
227
241
|
|
|
228
|
-
# Addressable 2.0.1
|
|
242
|
+
# Addressable 2.0.1 <a name="v2.0.1">
|
|
229
243
|
- fixed issue with query string assignment
|
|
230
244
|
- fixed issue with improperly encoded components
|
|
231
245
|
|
|
232
|
-
# Addressable 2.0.0
|
|
246
|
+
# Addressable 2.0.0 <a name="v2.0.0">
|
|
233
247
|
- the initialize method now takes an options hash as its only parameter
|
|
234
248
|
- added query_values method to URI class
|
|
235
249
|
- completely replaced IDNA implementation with pure Ruby
|
|
@@ -244,20 +258,20 @@
|
|
|
244
258
|
- updated URI Template code to match v 03 of the draft spec
|
|
245
259
|
- added a bunch of new specifications
|
|
246
260
|
|
|
247
|
-
# Addressable 1.0.4
|
|
261
|
+
# Addressable 1.0.4 <a name="v1.0.4">
|
|
248
262
|
- switched to using RSpec's pending system for specs that rely on IDN
|
|
249
263
|
- fixed issue with creating URIs with paths that are not prefixed with '/'
|
|
250
264
|
|
|
251
|
-
# Addressable 1.0.3
|
|
265
|
+
# Addressable 1.0.3 <a name="v1.0.3">
|
|
252
266
|
- implemented a hash method
|
|
253
267
|
|
|
254
|
-
# Addressable 1.0.2
|
|
268
|
+
# Addressable 1.0.2 <a name="v1.0.2">
|
|
255
269
|
- fixed minor bug with the extract_mapping method
|
|
256
270
|
|
|
257
|
-
# Addressable 1.0.1
|
|
271
|
+
# Addressable 1.0.1 <a name="v1.0.1">
|
|
258
272
|
- fixed minor bug with the extract_mapping method
|
|
259
273
|
|
|
260
|
-
# Addressable 1.0.0
|
|
274
|
+
# Addressable 1.0.0 <a name="v1.0.0">
|
|
261
275
|
- heuristic parse method added
|
|
262
276
|
- parsing is slightly more strict
|
|
263
277
|
- replaced to_h with to_hash
|
|
@@ -266,16 +280,16 @@
|
|
|
266
280
|
- improved heckle rake task
|
|
267
281
|
- no surviving heckle mutations
|
|
268
282
|
|
|
269
|
-
# Addressable 0.1.2
|
|
283
|
+
# Addressable 0.1.2 <a name="v0.1.2">
|
|
270
284
|
- improved normalization
|
|
271
285
|
- fixed bug in joining algorithm
|
|
272
286
|
- updated specifications
|
|
273
287
|
|
|
274
|
-
# Addressable 0.1.1
|
|
288
|
+
# Addressable 0.1.1 <a name="v0.1.1">
|
|
275
289
|
- updated documentation
|
|
276
290
|
- added URI Template variable extraction
|
|
277
291
|
|
|
278
|
-
# Addressable 0.1.0
|
|
292
|
+
# Addressable 0.1.0 <a name="v0.1.0">
|
|
279
293
|
- initial release
|
|
280
294
|
- implementation based on RFC 3986, 3987
|
|
281
295
|
- support for IRIs via libidn
|
data/Rakefile
CHANGED
|
@@ -20,12 +20,17 @@ additionally provides extensive support for IRIs and URI templates.
|
|
|
20
20
|
TEXT
|
|
21
21
|
|
|
22
22
|
PKG_FILES = FileList[
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
data/addressable.gemspec
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: addressable 2.8.
|
|
2
|
+
# stub: addressable 2.8.6 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "addressable".freeze
|
|
6
|
-
s.version = "2.8.
|
|
6
|
+
s.version = "2.8.6".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.6" } if s.respond_to? :metadata=
|
|
10
10
|
s.require_paths = ["lib".freeze]
|
|
11
11
|
s.authors = ["Bob Aman".freeze]
|
|
12
|
-
s.date = "2023-
|
|
12
|
+
s.date = "2023-12-09"
|
|
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.
|
|
21
|
+
s.rubygems_version = "3.4.22".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, "< 6.0".freeze])
|
|
27
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 1.0".freeze, "< 3.0".freeze])
|
|
28
28
|
end
|
data/lib/addressable/uri.rb
CHANGED
|
@@ -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 =
|
|
348
|
-
|
|
349
|
-
|
|
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 =
|
|
354
|
-
|
|
355
|
-
|
|
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 |
|
|
425
|
-
SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE[
|
|
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.
|
|
429
|
-
SEQUENCE_ENCODING_TABLE[
|
|
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
|
-
|
|
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
|
-
|
|
564
|
-
|
|
565
|
-
|
|
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::
|
|
633
|
+
Addressable::URI::CharacterClassesRegexps::SCHEME),
|
|
627
634
|
:authority => self.encode_component(uri_object.authority,
|
|
628
|
-
Addressable::URI::
|
|
635
|
+
Addressable::URI::CharacterClassesRegexps::AUTHORITY),
|
|
629
636
|
:path => self.encode_component(uri_object.path,
|
|
630
|
-
Addressable::URI::
|
|
637
|
+
Addressable::URI::CharacterClassesRegexps::PATH),
|
|
631
638
|
:query => self.encode_component(uri_object.query,
|
|
632
|
-
Addressable::URI::
|
|
639
|
+
Addressable::URI::CharacterClassesRegexps::QUERY),
|
|
633
640
|
:fragment => self.encode_component(uri_object.fragment,
|
|
634
|
-
Addressable::URI::
|
|
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::
|
|
706
|
+
Addressable::URI::CharacterClassesRegexps::SCHEME),
|
|
700
707
|
:user => self.encode_component(components[:user],
|
|
701
|
-
Addressable::URI::
|
|
708
|
+
Addressable::URI::CharacterClassesRegexps::UNRESERVED),
|
|
702
709
|
:password => self.encode_component(components[:password],
|
|
703
|
-
Addressable::URI::
|
|
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::
|
|
714
|
+
Addressable::URI::CharacterClassesRegexps::PATH),
|
|
708
715
|
:query => self.encode_component(components[:query],
|
|
709
|
-
Addressable::URI::
|
|
716
|
+
Addressable::URI::CharacterClassesRegexps::QUERY),
|
|
710
717
|
:fragment => self.encode_component(components[:fragment],
|
|
711
|
-
Addressable::URI::
|
|
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
|
-
|
|
769
|
+
CharacterClassesRegexps::UNRESERVED
|
|
763
770
|
).gsub("%20", "+"),
|
|
764
771
|
self.encode_component(
|
|
765
772
|
value.gsub(/(\r\n|\n|\r)/, "\r\n"),
|
|
766
|
-
|
|
773
|
+
CharacterClassesRegexps::UNRESERVED
|
|
767
774
|
).gsub("%20", "+")
|
|
768
775
|
]
|
|
769
776
|
end
|
|
@@ -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,
|
|
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,
|
|
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,
|
|
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 =
|
|
2598
|
+
NONE = Module.new.freeze
|
|
2573
2599
|
|
|
2574
2600
|
private_constant :NONE
|
|
2575
2601
|
end
|
data/lib/addressable/version.rb
CHANGED
|
@@ -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
|
@@ -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
|
|
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
|
+
version: 2.8.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bob Aman
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-12-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: public_suffix
|
|
@@ -91,7 +91,7 @@ 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
|
|
94
|
+
changelog_uri: https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md#v2.8.6
|
|
95
95
|
post_install_message:
|
|
96
96
|
rdoc_options:
|
|
97
97
|
- "--main"
|
|
@@ -109,7 +109,7 @@ 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.
|
|
112
|
+
rubygems_version: 3.4.22
|
|
113
113
|
signing_key:
|
|
114
114
|
specification_version: 4
|
|
115
115
|
summary: URI Implementation
|