ndr_support 5.9.5 → 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: 2bfe7ed2fab4ae654340e7aef5838dc71d904635ac4aa0d78dcee8b6d00ead31
4
- data.tar.gz: 4d2b22e57baaffd236846e3505fc1303391202a48e6b3e64867dd84ca9c4e61e
3
+ metadata.gz: 219d266e0a79fb3e013249e574aa25648ddecd15b49421cd66c06780d63f47e8
4
+ data.tar.gz: 48cdd5789a4aed8be6c03993eb4d1ce7ec6bf7e5225aea7e47f5e452c641d3d0
5
5
  SHA512:
6
- metadata.gz: 6d4eccd2e2c6fcf7813da447cac43f3e359057edb17af8476666ee9e40ecf71735738a5b0a0919f284a213e87c7c7d19750a78a5c17e9ac15bd7c1d3ee6a8445
7
- data.tar.gz: 424d016b5959104a7778724fb71d65d205b3b3d2f9c9bfca54ca3a3c1fb4b9f8d622f2d5bb3d5584fe81d138870613ba8ae28c01982d656be754e00efa44faab
6
+ metadata.gz: 869d57040385f645aae2c5b1c8dcefe5c2fd2176a7f8aa71f2859764edc7d9e0553a76065a92d29f98e3e1eb2bf29c6f8c1f0ee289e3314c90e0e105112f1cd6
7
+ data.tar.gz: dc2263d789b440b4a153c086b7049b5983e512af444fbb7f469161967685bbe4e130e7a68e63e5e14e5f4e494804a049f662fbd973e6588dddbb3a6065452902
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
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
+
8
+ ## 5.9.6 / 2023-11-14
9
+ ## Fixed
10
+ * YAMLSupport should preserve escape sequences in JSON text
11
+
4
12
  ## 5.9.5 / 2023-10-26
5
13
  * Support Rails 7.1
6
14
 
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: 2253a90ec8db872590a8167fdebe95d6ed677cc2
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: 45fa90daa2dd131ac0286ef7f4af1447bd01bc6c
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: f4f7cb0803ea34a2f1ba83495d8bcbd942786bce
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: f4f7cb0803ea34a2f1ba83495d8bcbd942786bce
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.5'
6
+ VERSION = '5.9.7'
7
7
  end
@@ -56,11 +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)
61
+ return unless string.start_with?('---') # Only handle YAML that is not JSON
62
+
60
63
  # Replace any encoded hex chars with their actual value:
61
- string.gsub!(/((?:\\x[0-9A-F]{2})+)/) do
62
- byte_sequence = $1.scan(/[0-9A-F]{2}/)
63
- 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|
64
70
  fix_encoding!(sequence, coerce_invalid_chars)
65
71
  end
66
72
  end
@@ -29,6 +29,17 @@ 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
+
38
+ test 'should leave non-binary JSON with things that look like control chars unchanged' do
39
+ hash = { 'report' => ' \x01 ' }
40
+ assert_equal hash, load_yaml(hash.to_json)
41
+ end
42
+
32
43
  test 'load_yaml should not coerce to UTF-8 by default' do
33
44
  assert_yaml_coercion_behaviour
34
45
  end
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.5
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-10-26 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