ndr_support 5.9.6 → 5.9.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/code_safety.yml +4 -4
- data/lib/ndr_support/version.rb +1 -1
- data/lib/ndr_support/yaml/serialization_migration.rb +7 -4
- data/test/yaml/serialization_test.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 219d266e0a79fb3e013249e574aa25648ddecd15b49421cd66c06780d63f47e8
|
4
|
+
data.tar.gz: 48cdd5789a4aed8be6c03993eb4d1ce7ec6bf7e5225aea7e47f5e452c641d3d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 869d57040385f645aae2c5b1c8dcefe5c2fd2176a7f8aa71f2859764edc7d9e0553a76065a92d29f98e3e1eb2bf29c6f8c1f0ee289e3314c90e0e105112f1cd6
|
7
|
+
data.tar.gz: dc2263d789b440b4a153c086b7049b5983e512af444fbb7f469161967685bbe4e130e7a68e63e5e14e5f4e494804a049f662fbd973e6588dddbb3a6065452902
|
data/CHANGELOG.md
CHANGED
data/code_safety.yml
CHANGED
@@ -23,7 +23,7 @@ file safety:
|
|
23
23
|
CHANGELOG.md:
|
24
24
|
comments:
|
25
25
|
reviewed_by: brian.shand
|
26
|
-
safe_revision:
|
26
|
+
safe_revision: ead7b5fe38f4f580d5c4ca2697136acc8ef1bd8b
|
27
27
|
CODE_OF_CONDUCT.md:
|
28
28
|
comments:
|
29
29
|
reviewed_by: timgentry
|
@@ -171,7 +171,7 @@ file safety:
|
|
171
171
|
lib/ndr_support/version.rb:
|
172
172
|
comments:
|
173
173
|
reviewed_by: brian.shand
|
174
|
-
safe_revision:
|
174
|
+
safe_revision: 9a91fe5935711475449aebbb6b93bd9f40884a77
|
175
175
|
lib/ndr_support/working_days.rb:
|
176
176
|
comments:
|
177
177
|
reviewed_by: josh.pencheon
|
@@ -179,7 +179,7 @@ file safety:
|
|
179
179
|
lib/ndr_support/yaml/serialization_migration.rb:
|
180
180
|
comments:
|
181
181
|
reviewed_by: brian.shand
|
182
|
-
safe_revision:
|
182
|
+
safe_revision: ead7b5fe38f4f580d5c4ca2697136acc8ef1bd8b
|
183
183
|
ndr_support.gemspec:
|
184
184
|
comments:
|
185
185
|
reviewed_by: brian.shand
|
@@ -283,4 +283,4 @@ file safety:
|
|
283
283
|
test/yaml/serialization_test.rb:
|
284
284
|
comments:
|
285
285
|
reviewed_by: brian.shand
|
286
|
-
safe_revision:
|
286
|
+
safe_revision: ead7b5fe38f4f580d5c4ca2697136acc8ef1bd8b
|
data/lib/ndr_support/version.rb
CHANGED
@@ -56,14 +56,17 @@ module NdrSupport
|
|
56
56
|
# Within double quotes, YAML allows special characters.
|
57
57
|
# While `psych` emits UTF-8 YAML, `syck` double escapes
|
58
58
|
# higher characters. We need to unescape any we find:
|
59
|
+
# Both `psych` and `syck` escape lower control characters.
|
59
60
|
def handle_special_characters!(string, coerce_invalid_chars)
|
60
|
-
# TODO: Change to only handle syck control characters
|
61
61
|
return unless string.start_with?('---') # Only handle YAML that is not JSON
|
62
62
|
|
63
63
|
# Replace any encoded hex chars with their actual value:
|
64
|
-
string.gsub!(/((?:\\x[0-9A-F]{2})+)/) do
|
65
|
-
|
66
|
-
|
64
|
+
string.gsub!(/(?<!\\)((?:\\\\)*)((?:\\x[0-9A-F]{2})+)/) do
|
65
|
+
# We use negative lookbehind and the first capturing group to skip over
|
66
|
+
# properly escaped backslashes
|
67
|
+
prefix = ::Regexp.last_match(1) # Prefix is an even number of backslashes
|
68
|
+
byte_sequence = ::Regexp.last_match(2).scan(/[0-9A-F]{2}/)
|
69
|
+
prefix + byte_sequence.pack('H2' * byte_sequence.length).tap do |sequence|
|
67
70
|
fix_encoding!(sequence, coerce_invalid_chars)
|
68
71
|
end
|
69
72
|
end
|
@@ -29,8 +29,14 @@ class SerializationTest < Minitest::Test
|
|
29
29
|
assert_equal "control 0x01 char \n whoops!", load_yaml(chr_1_yaml)
|
30
30
|
end
|
31
31
|
|
32
|
+
test 'should handle non-binary yaml with escaped things that look like control chars' do
|
33
|
+
# irb> Psych.dump(['\\x01 \\xAF \\\\xAF', "\x01 \\\x01 \x01\\\x01"])
|
34
|
+
escaped_yaml = "---\n- \"\\\\x01 \\\\xAF \\\\\\\\xAF\"\n- \"\\x01 \\\\\\x01 \\x01\\\\\\x01\"\n"
|
35
|
+
assert_equal ['\\x01 \\xAF \\\\xAF', '0x01 \\0x01 0x01\\0x01'], load_yaml(escaped_yaml)
|
36
|
+
end
|
37
|
+
|
32
38
|
test 'should leave non-binary JSON with things that look like control chars unchanged' do
|
33
|
-
hash = { 'report' => ' \
|
39
|
+
hash = { 'report' => ' \x01 ' }
|
34
40
|
assert_equal hash, load_yaml(hash.to_json)
|
35
41
|
end
|
36
42
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ndr_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.9.
|
4
|
+
version: 5.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NCRS Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|