json_mend 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d35f7c9f36e19aad3676320c0d23913ee95f9e92d391587732baa6ab849aeb03
4
- data.tar.gz: fbf7a08168984cd2d8c5cd3efcdd93559df98c749d3c8b0dff5393d7b16b6817
3
+ metadata.gz: 9a3bfc54ceae164d2837fbcdf3751e79359397b735693ec990954fee19bfa60e
4
+ data.tar.gz: 2dfea1b0a6ada799891385ec4c35a83153005f5b344e23b7a9921c726a94c220
5
5
  SHA512:
6
- metadata.gz: dd89121f4e73649f762d01e360838364f91f88cb0fe8f56ef158840d41f2c863e916c572625a913a90334332adeb2e2f8e4213f0962a26e34704616d4756b071
7
- data.tar.gz: fe6fd2bc78b8d25b7ee25f00148e8f65b75cdeeef5faadf45efd514d1463f793cf80390d2be00d5af1d4e5b2f5a211079e91f85682dd5dd050a5679d4542a274
6
+ metadata.gz: '0592fea3e3859aaafbc6b2508b03de3a54eefd17e4520375ce1163e929ed24be10ad16b2936db2175ec79d9f9f4dd7acbd82ba72b50c3df3ea347ffe8436ded6'
7
+ data.tar.gz: 6708504ef9b2c1f68f0bdc1da889c254580a169066d37db99993468f78bcb9c3f8ca351dfaafecbc62780d319c12e51a4536b6da70a589d450ead3f407ed8ea7
@@ -787,7 +787,9 @@ module JsonMend
787
787
  bk = 1
788
788
  slashes = 0
789
789
  # Look back in the string buffer directly for speed
790
- while (char_code = @scanner.string.getbyte(@scanner.pos - 1 - bk)) && char_code == 92 # 92 is backslash
790
+ while (@scanner.pos - 1 - bk >= 0) &&
791
+ (char_code = @scanner.string.getbyte(@scanner.pos - 1 - bk)) &&
792
+ char_code == 92 # 92 is backslash
791
793
  slashes += 1
792
794
  bk += 1
793
795
  end
@@ -1144,20 +1146,24 @@ module JsonMend
1144
1146
 
1145
1147
  if context_contain?(:object_key)
1146
1148
  # If parsing a key, we must stop at ':' and structural closers
1147
- @scanner.scan_until(/(?=[\n\r:}\]])/)
1149
+ @scanner.scan_until(/(?=[\n\r:}\]]|\\n|\\r)/) || @scanner.terminate
1148
1150
  elsif in_array && in_object
1149
1151
  # Nested ambiguity, stop at any closer
1150
- @scanner.scan_until(/(?=[\n\r}\]])/)
1152
+ @scanner.scan_until(/(?=[\n\r}\]]|\\n|\\r)/) || @scanner.terminate
1151
1153
  elsif in_array
1152
1154
  # Inside array, stop at ']'
1153
- @scanner.scan_until(/(?=[\n\r\]])/)
1155
+ @scanner.scan_until(/(?=[\n\r\]]|\\n|\\r)/) || @scanner.terminate
1154
1156
  elsif in_object
1155
1157
  # Inside object value, stop at '}'
1156
- @scanner.scan_until(/(?=[\n\r}])/)
1158
+ @scanner.scan_until(/(?=[\n\r}]|\\n|\\r)/) || @scanner.terminate
1157
1159
  else
1158
1160
  # Top level or neutral, stop at newline
1159
- @scanner.scan_until(/(?=[\n\r])/)
1161
+ @scanner.scan_until(/(?=[\n\r]|\\n|\\r)/) || @scanner.terminate
1160
1162
  end
1163
+
1164
+ # Consume literal escaped newlines so they don't break subsequent parsing.
1165
+ # (Real newlines will be left alone here and consumed normally by skip_whitespaces).
1166
+ @scanner.skip(/\\n|\\r/)
1161
1167
  else
1162
1168
  # The character at the current position (likely '/') is not the start of a
1163
1169
  # valid comment. To prevent an infinite loop in the calling parser, we must
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JsonMend
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_mend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleksii Vasyliev