ndr_support 5.9.6 → 5.9.7

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: 7447cd235fe9715cc6e6c868b0f0048c7ec516b70ea88e323dcdc1fd01e24f11
4
- data.tar.gz: 16b4237428fdf1258327ebc86928c4f3cc8db292289ff8151db364f77c505439
3
+ metadata.gz: 219d266e0a79fb3e013249e574aa25648ddecd15b49421cd66c06780d63f47e8
4
+ data.tar.gz: 48cdd5789a4aed8be6c03993eb4d1ce7ec6bf7e5225aea7e47f5e452c641d3d0
5
5
  SHA512:
6
- metadata.gz: 186d4b1f8f053e9fa2cba311d7f9760e496ea8597dbea5c7e3e1d34c62fe6237df8c51692ff40a18f98085b58dc9a98942a54b94854b0e32ea30e4033e9d9aa3
7
- data.tar.gz: 68ada778e3d6d7b9187f5b95398f408ff08940e0c77f5019a99611279ff4e1bbb9a5bfacd32ed3c0082bfb607ecc93df158ef2399b414d53a0e0bc7c53c0727a
6
+ metadata.gz: 869d57040385f645aae2c5b1c8dcefe5c2fd2176a7f8aa71f2859764edc7d9e0553a76065a92d29f98e3e1eb2bf29c6f8c1f0ee289e3314c90e0e105112f1cd6
7
+ data.tar.gz: dc2263d789b440b4a153c086b7049b5983e512af444fbb7f469161967685bbe4e130e7a68e63e5e14e5f4e494804a049f662fbd973e6588dddbb3a6065452902
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  ## [Unreleased]
2
2
  * No unreleased changes
3
3
 
4
+ ## 5.9.7 / 2023-11-16
5
+ ## Fixed
6
+ * YAMLSupport should preserve escaped backslashes in YAML text
7
+
4
8
  ## 5.9.6 / 2023-11-14
5
9
  ## Fixed
6
10
  * YAMLSupport should preserve escape sequences in JSON text
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: '09ad2e0c210d3e4377de68dac3d54932df6c1994'
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: 26236a310377036e1a27eb9534b4167430da6f3c
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: '09ad2e0c210d3e4377de68dac3d54932df6c1994'
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: '09ad2e0c210d3e4377de68dac3d54932df6c1994'
286
+ safe_revision: ead7b5fe38f4f580d5c4ca2697136acc8ef1bd8b
@@ -3,5 +3,5 @@
3
3
  # This defines the NdrSupport version. If you change it, rebuild and commit the gem.
4
4
  # Use "rake build" to build the gem, see rake -T for all bundler rake tasks.
5
5
  module NdrSupport
6
- VERSION = '5.9.6'
6
+ VERSION = '5.9.7'
7
7
  end
@@ -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
- byte_sequence = $1.scan(/[0-9A-F]{2}/)
66
- byte_sequence.pack('H2' * byte_sequence.length).tap do |sequence|
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' => ' \x09 ' }
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.6
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-14 00:00:00.000000000 Z
11
+ date: 2023-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord