json 2.18.2 → 2.18.3

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: 1c725c4afdd182aa9252219b897ebf6e4e4ded09d84950cb757fefb8e23fb582
4
- data.tar.gz: ae073b566faf0998934386dbc58cbbf3a1c9df5f37dac8ef739caa9ec5a426a1
3
+ metadata.gz: f2f4e92c83082e5be91872a463b47a8520d0f6b7aae8799bab0d012297065685
4
+ data.tar.gz: 3149e9053445d1ae0397b30bdb95c0f26ed5c56e36506c065e843a37809cd5c5
5
5
  SHA512:
6
- metadata.gz: dc293a2d227101f5feb1dafd1ac26f97292c0056cfb0b9ee4cf370796b5b80c290096231dfc855f3e282b7cfe552156b46cdc5f99f8c3e9a425ede1dc49c0a04
7
- data.tar.gz: b98ec5d804d52c6c3d1c5ccf57a7bf4912528149792fd8442e5db49938b77b6943293a1d2734b00cf7db934ed82a839b61eb1c107a7fd0b3a7663b76315b52f1
6
+ metadata.gz: b618febef7ab94710d390a2aab3b3af62080feb5f97dbc1217a94dce790cb5b93837bfd7c2f66eecbdb1358844e7c83b404b1124583a87d73e18f5dd28512b72
7
+ data.tar.gz: 56bed6163cbd092c20fbf4e0ddaf3ecdcf69bc3cc3228ad7407215d9b3aacd8c18b4ddfd0536f23a6d2e19d8fc4ed794b022f987abf44da10bbfef6336c60928
data/CHANGES.md CHANGED
@@ -2,11 +2,15 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
- ### 2026-11-02 (2.18.2)
5
+ ### 2026-11-13 (2.18.3)
6
6
 
7
- * Backport handling of unescaped control characters preceeded by a backslash from 2.19.3.
7
+ * Backport handling of unescaped control characters preceeded by a backslash from 2.19.2.
8
8
  GHSA-cjpr-jw2g-fw99.
9
9
 
10
+ ### 2026-11-02 (2.18.2)
11
+
12
+ * Fix a format string injection vulnerability in `JSON.parse(doc, allow_duplicate_key: false)`.
13
+
10
14
  ### 2026-02-03 (2.18.1)
11
15
 
12
16
  * Fix a potential crash in very specific circumstance if GC triggers during a call to `to_json`
@@ -400,14 +400,9 @@ static void emit_parse_warning(const char *message, JSON_ParserState *state)
400
400
 
401
401
  #define PARSE_ERROR_FRAGMENT_LEN 32
402
402
 
403
- #ifdef RBIMPL_ATTR_NORETURN
404
- RBIMPL_ATTR_NORETURN()
405
- #endif
406
- static void raise_parse_error(const char *format, JSON_ParserState *state)
403
+ static VALUE build_parse_error_message(const char *format, JSON_ParserState *state, long line, long column)
407
404
  {
408
405
  unsigned char buffer[PARSE_ERROR_FRAGMENT_LEN + 3];
409
- long line, column;
410
- cursor_position(state, &line, &column);
411
406
 
412
407
  const char *ptr = "EOF";
413
408
  if (state->cursor && state->cursor < state->end) {
@@ -442,11 +437,23 @@ static void raise_parse_error(const char *format, JSON_ParserState *state)
442
437
  VALUE msg = rb_sprintf(format, ptr);
443
438
  VALUE message = rb_enc_sprintf(enc_utf8, "%s at line %ld column %ld", RSTRING_PTR(msg), line, column);
444
439
  RB_GC_GUARD(msg);
440
+ return message;
441
+ }
445
442
 
443
+ static VALUE parse_error_new(VALUE message, long line, long column)
444
+ {
446
445
  VALUE exc = rb_exc_new_str(rb_path2class("JSON::ParserError"), message);
447
446
  rb_ivar_set(exc, rb_intern("@line"), LONG2NUM(line));
448
447
  rb_ivar_set(exc, rb_intern("@column"), LONG2NUM(column));
449
- rb_exc_raise(exc);
448
+ return exc;
449
+ }
450
+
451
+ NORETURN(static) void raise_parse_error(const char *format, JSON_ParserState *state)
452
+ {
453
+ long line, column;
454
+ cursor_position(state, &line, &column);
455
+ VALUE message = build_parse_error_message(format, state, line, column);
456
+ rb_exc_raise(parse_error_new(message, line, column));
450
457
  }
451
458
 
452
459
  #ifdef RBIMPL_ATTR_NORETURN
@@ -888,6 +895,11 @@ static void raise_duplicate_key_error(JSON_ParserState *state, VALUE duplicate_k
888
895
  rb_inspect(duplicate_key)
889
896
  );
890
897
 
898
+ long line, column;
899
+ cursor_position(state, &line, &column);
900
+ rb_str_concat(message, build_parse_error_message("", state, line, column)) ;
901
+ rb_exc_raise(parse_error_new(message, line, column));
902
+
891
903
  raise_parse_error(RSTRING_PTR(message), state);
892
904
  RB_GC_GUARD(message);
893
905
  }
data/lib/json/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSON
4
- VERSION = '2.18.2'
4
+ VERSION = '2.18.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.18.2
4
+ version: 2.18.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank