addressable 2.8.3 → 2.8.5
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 +14 -0
- data/Rakefile +11 -6
- data/addressable.gemspec +4 -4
- data/lib/addressable/idna/native.rb +10 -0
- data/lib/addressable/idna/pure.rb +10 -0
- data/lib/addressable/uri.rb +34 -19
- data/lib/addressable/version.rb +1 -1
- data/spec/addressable/uri_spec.rb +39 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b7d4ea3b683b3b7c719ae54919505e8e98823b39e54cd68d3579319b61d9824
|
4
|
+
data.tar.gz: d09b61eba34544826aec64909b848b53549ae64059e09cc5f462991a59fd2465
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37927e878581e256a98ac619723a90f7b7a2d5b655ef613872a4f963ffdccabc6f0b761b65673fc6929509b0f783b48460b2643ac33c2d076bc5234e4126573b
|
7
|
+
data.tar.gz: 3afd1d272e41f97959bc8b34188b8d9fc419fcc01af9ea8a955d3ee2e6f57e3417d5ec6c58378e6b29fedb15e948ace7c080cd2c3739d6e24a4dd04eb3fa3f70
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# Addressable 2.8.5
|
2
|
+
- Fix thread safety issue with encoding tables ([#515])
|
3
|
+
- Define URI::NONE as a module to avoid serialization issues ([#509])
|
4
|
+
- Fix YAML serialization ([#508])
|
5
|
+
|
6
|
+
[#508]: https://github.com/sporkmonger/addressable/pull/508
|
7
|
+
[#509]: https://github.com/sporkmonger/addressable/pull/509
|
8
|
+
[#515]: https://github.com/sporkmonger/addressable/pull/515
|
9
|
+
|
10
|
+
# Addressable 2.8.4
|
11
|
+
- Restore `Addressable::IDNA.unicode_normalize_kc` as a deprecated method ([#504])
|
12
|
+
|
13
|
+
[#504]: https://github.com/sporkmonger/addressable/pull/504
|
14
|
+
|
1
15
|
# Addressable 2.8.3
|
2
16
|
- Fix template expand level 2 hash support for non-string objects ([#499], [#498])
|
3
17
|
|
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.5 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.5"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.metadata = { "changelog_uri" => "https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md" } 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-08-03"
|
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,7 +18,7 @@ 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.18".freeze
|
22
22
|
s.summary = "URI Implementation".freeze
|
23
23
|
|
24
24
|
s.specification_version = 4
|
@@ -29,6 +29,16 @@ module Addressable
|
|
29
29
|
IDN::Punycode.decode(value.to_s)
|
30
30
|
end
|
31
31
|
|
32
|
+
class << self
|
33
|
+
# @deprecated Use {String#unicode_normalize(:nfkc)} instead
|
34
|
+
def unicode_normalize_kc(value)
|
35
|
+
value.to_s.unicode_normalize(:nfkc)
|
36
|
+
end
|
37
|
+
|
38
|
+
extend Gem::Deprecate
|
39
|
+
deprecate :unicode_normalize_kc, "String#unicode_normalize(:nfkc)", 2023, 4
|
40
|
+
end
|
41
|
+
|
32
42
|
def self.to_ascii(value)
|
33
43
|
value.to_s.split('.', -1).map do |segment|
|
34
44
|
if segment.size > 0 && segment.size < 64
|
@@ -112,6 +112,16 @@ module Addressable
|
|
112
112
|
output
|
113
113
|
end
|
114
114
|
|
115
|
+
class << self
|
116
|
+
# @deprecated Use {String#unicode_normalize(:nfkc)} instead
|
117
|
+
def unicode_normalize_kc(value)
|
118
|
+
value.to_s.unicode_normalize(:nfkc)
|
119
|
+
end
|
120
|
+
|
121
|
+
extend Gem::Deprecate
|
122
|
+
deprecate :unicode_normalize_kc, "String#unicode_normalize(:nfkc)", 2023, 4
|
123
|
+
end
|
124
|
+
|
115
125
|
##
|
116
126
|
# Unicode aware downcase method.
|
117
127
|
#
|
data/lib/addressable/uri.rb
CHANGED
@@ -344,17 +344,13 @@ module Addressable
|
|
344
344
|
##
|
345
345
|
# Tables used to optimize encoding operations in `self.encode_component`
|
346
346
|
# and `self.normalize_component`
|
347
|
-
SEQUENCE_ENCODING_TABLE =
|
348
|
-
|
349
|
-
|
350
|
-
end.join
|
351
|
-
end
|
347
|
+
SEQUENCE_ENCODING_TABLE = (0..255).map do |byte|
|
348
|
+
format("%02x", byte).freeze
|
349
|
+
end.freeze
|
352
350
|
|
353
|
-
SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE =
|
354
|
-
|
355
|
-
|
356
|
-
end.join
|
357
|
-
end
|
351
|
+
SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE = (0..255).map do |byte|
|
352
|
+
format("%%%02X", byte).freeze
|
353
|
+
end.freeze
|
358
354
|
|
359
355
|
##
|
360
356
|
# Percent encodes a URI component.
|
@@ -421,16 +417,17 @@ module Addressable
|
|
421
417
|
component = component.dup
|
422
418
|
component.force_encoding(Encoding::ASCII_8BIT)
|
423
419
|
# Avoiding gsub! because there are edge cases with frozen strings
|
424
|
-
component = component.gsub(character_class) do |
|
425
|
-
SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE[
|
420
|
+
component = component.gsub(character_class) do |char|
|
421
|
+
SEQUENCE_UPCASED_PERCENT_ENCODING_TABLE[char.ord]
|
426
422
|
end
|
427
423
|
if upcase_encoded.length > 0
|
428
|
-
upcase_encoded_chars = upcase_encoded.
|
429
|
-
SEQUENCE_ENCODING_TABLE[
|
424
|
+
upcase_encoded_chars = upcase_encoded.bytes.map do |byte|
|
425
|
+
SEQUENCE_ENCODING_TABLE[byte]
|
430
426
|
end
|
431
427
|
component = component.gsub(/%(#{upcase_encoded_chars.join('|')})/,
|
432
428
|
&:upcase)
|
433
429
|
end
|
430
|
+
|
434
431
|
return component
|
435
432
|
end
|
436
433
|
|
@@ -560,10 +557,9 @@ module Addressable
|
|
560
557
|
leave_re = if leave_encoded.length > 0
|
561
558
|
character_class = "#{character_class}%" unless character_class.include?('%')
|
562
559
|
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
end.join('|')})"
|
560
|
+
bytes = leave_encoded.bytes
|
561
|
+
leave_encoded_pattern = bytes.map { |b| SEQUENCE_ENCODING_TABLE[b] }.join('|')
|
562
|
+
"|%(?!#{leave_encoded_pattern}|#{leave_encoded_pattern.upcase})"
|
567
563
|
end
|
568
564
|
|
569
565
|
character_class = if leave_re
|
@@ -2396,6 +2392,25 @@ module Addressable
|
|
2396
2392
|
@validation_deferred = false
|
2397
2393
|
end
|
2398
2394
|
|
2395
|
+
def encode_with(coder)
|
2396
|
+
instance_variables.each do |ivar|
|
2397
|
+
value = instance_variable_get(ivar)
|
2398
|
+
if value != NONE
|
2399
|
+
key = ivar.to_s.slice(1..-1)
|
2400
|
+
coder[key] = value
|
2401
|
+
end
|
2402
|
+
end
|
2403
|
+
nil
|
2404
|
+
end
|
2405
|
+
|
2406
|
+
def init_with(coder)
|
2407
|
+
reset_ivs
|
2408
|
+
coder.map.each do |key, value|
|
2409
|
+
instance_variable_set("@#{key}", value)
|
2410
|
+
end
|
2411
|
+
nil
|
2412
|
+
end
|
2413
|
+
|
2399
2414
|
protected
|
2400
2415
|
SELF_REF = '.'
|
2401
2416
|
PARENT = '..'
|
@@ -2569,7 +2584,7 @@ module Addressable
|
|
2569
2584
|
@query = nil
|
2570
2585
|
end
|
2571
2586
|
|
2572
|
-
NONE =
|
2587
|
+
NONE = Module.new.freeze
|
2573
2588
|
|
2574
2589
|
private_constant :NONE
|
2575
2590
|
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
|
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.5
|
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-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: public_suffix
|
@@ -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.18
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: URI Implementation
|