803 Commits
Author SHA1 Message Date
Sebastian Turner 63ae538ecf [ruby/json] Fix ParserError#json_path with symbolize_names: true
Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>

https://github.com/ruby/json/commit/c839870678
2026-10-19 16:25:24 +00:00
Hiroshi SHIBATAandClaude Opus 5.5 76f0a79179 [ruby/json] Drop the leftovers of runtime SSE2 detection
Neither the `__builtin_cpu_supports` probe in conf.rb nor `cpuid.h` has a use now that SSE2 is assumed on x86-64. The probe kept SIMD off on GCC older than 4.8, and the `HAVE_CPUID_H` guard broke builds that have `x86intrin.h` but not `cpuid.h` with a redefinition of `find_simd_implementation`.

https://github.com/ruby/json/commit/fae76b9eb4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 07:01:06 +00:00
Hiroshi SHIBATAandClaude Opus 5.5 2f88a23ad0 json: Use SSE2 on x86-64 without checking at runtime
__builtin_cpu_supports refers to __cpu_model in compiler-rt, which clang-cl does not link, so generator.so and parser.so failed with an undefined symbol. SSE2 is part of the x86-64 baseline, as NEON is for AArch64, where no check is made either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 13:39:04 +09:00
Jean Boussier 53e7d061f9 [ruby/json] Release 3.1.0
https://github.com/ruby/json/commit/a15b2ba603
2026-10-13 08:04:57 +00:00
Jean Boussier 72afd0b0d9 [ruby/json] Refactor rfc8785_sort_keys_proc
https://github.com/ruby/json/commit/d09e383d19
2026-10-13 07:32:24 +00:00
Jean Boussier ad29ad7ad8 [ruby/json] Handle invalid encoding in JSON path keys
https://github.com/ruby/json/commit/e19f7d75a6
2026-10-12 14:55:31 +00:00
Jean Boussier 86f192cf38 [ruby/json] parser.c: only update the stack once fully spilled
https://github.com/ruby/json/commit/78d6a83a3c
2026-10-12 14:28:23 +00:00
Jean Boussier c5597ac4bd [ruby/json] Fix parsing of number with out of range negative exponents
https://github.com/ruby/json/commit/6ea62016fb
2026-10-12 14:22:32 +00:00
Jean Boussier 817023b888 [ruby/json] Fix parsing of unescaped NULL bytes in strings
https://github.com/ruby/json/commit/1b67eb3db2
2026-10-12 13:57:23 +00:00
Jean Boussier 90e7ab3ade [ruby/json] ResumableParser: fix handling of incomplete unicode escape
`spe` is the string end, so if the escape is incomplete, it doesn't
mean we reached the end of stream, hence it's a syntax error, not
an EOS error.

https://github.com/ruby/json/commit/c1a4372837
2026-10-12 13:51:08 +00:00
Jean Boussier 0e01c2a87f [ruby/json] More hardening against adversarial encode methods
https://github.com/ruby/json/commit/429c109458
2026-10-12 08:15:47 +00:00
Hiroshi SHIBATAandClaude Opus 5.5 78a31f6735 [ruby/json] Index the generated JSON array by rb_len_t
An int index overflows on an Array longer than INT_MAX, which LP64 and now mswin can hold.

https://github.com/ruby/json/commit/8df32ab074

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 10:11:24 +02:00
ydah dbd87dcc28 [ruby/json] Sort RFC 8785 keys after as_json conversion
https://github.com/ruby/json/commit/88b358d8b2
2026-10-12 07:15:16 +00:00
Hiroshi SHIBATAandClaude Opus 5.5 87e6f05163 Use rb_len_t for String lengths and positions in json
The column of a parse error is a character position in the source, so it follows them while the line number stays long. It falls back to long on Ruby versions that do not define HAVE_RB_LEN_T.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 08:10:53 +09:00
Jean Boussier 870969b201 [ruby/json] Better defend against to_s or encode not returning a T_STRING
https://github.com/ruby/json/commit/cdcfdb8066
2026-10-08 18:50:44 +00:00
ydah 95db6abe45 [ruby/json] Reject incompatible RFC 8785 generation options
https://github.com/ruby/json/commit/49e8df0e16
2026-10-08 09:57:55 +00:00
ydah 87c567e721 [ruby/json] Canonicalize integers as doubles in RFC 8785 mode
https://github.com/ruby/json/commit/3d9d6dd32d
2026-10-08 07:05:47 +00:00
ydah 9d46512aab [ruby/json] Fix RFC 8785 number formatter spelling
https://github.com/ruby/json/commit/3e3807c82a
2026-10-07 14:36:49 +00:00
ydah 432e0dc577 [ruby/json] Sort RFC 8785 object properties by their keys
https://github.com/ruby/json/commit/808577ae1d
2026-10-07 14:36:31 +00:00
ydah 1ebc88b530 [ruby/json] Preserve float precision in RFC 8785 number formatting
https://github.com/ruby/json/commit/193df55852
2026-10-07 13:03:24 +00:00
ydah 9d5345460e [ruby/json] Report the attempted depth in generator nesting errors
https://github.com/ruby/json/commit/37a48ef6b8
2026-10-06 13:01:32 +00:00
ydah a51a35c506 [ruby/json] Reject non-ASCII BINARY strings during JSON generation
https://github.com/ruby/json/commit/8bab92d63b
2026-10-06 12:09:48 +00:00
ydah 2c1e694a53 [ruby/json] Exclude custom instance variables from State#to_h
https://github.com/ruby/json/commit/08e72297b2
2026-10-05 15:26:55 +00:00
ydah 156c095332 [ruby/json] Honor as_json and reject disabled strict mode in JSON::Coder
https://github.com/ruby/json/commit/b63b4f1506
2026-10-05 13:45:41 +00:00
Jean Boussier 6930c20b65 [ruby/json] Implement rfc8785
Fix: https://github.com/ruby/json/issues/1038

Directly lift https://github.com/dryruby/json-canonicalization

At least for now, implementing most of the logic in Ruby make it
shareable between the 3 generator implementations, largely reducing
the maintenance cost.

I don't particularly expect canonicalization to be a hotspot,
but if it happens to be, I'd be open to specialize the implementation,
within reason, at least in the C generator.

https://github.com/ruby/json/commit/f103c8953f
2026-10-02 14:45:31 +00:00
ydah 8cf3b6691f [ruby/json] Fix parser error positions for newlines and multibyte characters
https://github.com/ruby/json/commit/590dd5448d
2026-10-02 13:03:45 +00:00
ydah a349827f06 [ruby/json] Preserve complete UTF-8 characters in parse error snippets
https://github.com/ruby/json/commit/c484f8fa82
2026-10-02 12:21:27 +00:00
ydah 05479caf57 [ruby/json] Remove the leading space from Fragment conversion errors
https://github.com/ruby/json/commit/0c46c27fae
2026-10-01 07:15:23 +00:00
ydah d7e3bfc791 [ruby/json] Correct State as_json and depth setter documentation
https://github.com/ruby/json/commit/3643231dfd
2026-10-01 07:15:23 +00:00
ydah ad5851e797 [ruby/json] Prevent use-after-free when strings change during IO generation
https://github.com/ruby/json/commit/f720614728
2026-10-01 06:31:16 +00:00
ydah f452e5403e [ruby/json] Prevent ResumableParser from stalling on invalid object keys
https://github.com/ruby/json/commit/452f31b569
2026-10-01 06:21:36 +00:00
ydah 4f9ec01a51 [ruby/json] Prevent crashes with non-Proc on_load callbacks
Convert non-Proc on_load callbacks through to_proc and validate the result in the shared parser configuration. Previously, arbitrary values were stored and passed directly to rb_proc_call_with_block.

Cover Method callbacks in JSON.parse, JSON::Coder, and ResumableParser, along with invalid types, invalid conversion results, and nil or false callbacks.

https://github.com/ruby/json/commit/672da19fd5
2026-09-30 15:42:28 +00:00
Lucas Dohmen 7da1b1c7a0 [ruby/json] Fix Interoperability with Zlib::GzipReader
GzipReader offers both a read and to_io method. The read method returns
the uncompressed file as a string. The to_io method returns the
compressed file. The JSON.load method first tests for the to_io method
and uses it before testing for the read method. This results in reading
the compressed file, which is invalid JSON.

Instead, we now test for the read method first.

https://github.com/ruby/json/commit/b6a5d35245
2026-09-30 13:46:09 +00:00
ydah 9d7551d8c2 [ruby/json] Prevent crashes with non-Proc as_json callbacks
Convert non-Proc callbacks through to_proc and validate the result in both configuration and the as_json setter. rb_convert_type accepts unrelated T_DATA objects without conversion, allowing them to reach Proc APIs and crash.

Cover Method callbacks, invalid callback types, and to_proc returning a non-Proc object.

https://github.com/ruby/json/commit/f5c889de9c
2026-09-30 13:42:11 +00:00
Jean Boussier 5fe7d61b20 [ruby/json] Ensure default_sort_keys_proc isn't reassigned.
It's assignable from Ruby simply for the gem's own initialization,
but it should never be re-assigned later.

Fix: https://github.com/ruby/json/pull/1079

https://github.com/ruby/json/commit/cc32ef5cf5
2026-09-28 18:59:04 +02:00
Matt Valentine-House 43b1e17d08 json: reject non-shareable default sort_keys proc from non-main Ractors
JSON::State.default_sort_keys_proc is registered at extension load time
so it's owned by the main Ractor.

When we implement the registration table on each Ractor storing another
Ractor's unshareable Proc into that slot leaves a dangling reference
when the owning Ractor runs a local GC.

This commit ensures that we won't use a shareable proc by raising a
Ractor::IsolationError.
2026-09-25 19:24:10 +01:00
Jean Boussier 344fa79bc6 [ruby/json] Release 3.0.2
https://github.com/ruby/json/commit/7b2a23deea
2026-09-09 06:24:00 +00:00
Douglas Eichelberger 967e607789 [ruby/json] Fix the JSON::Coder.new call-seq
`JSON` has no `.new`, and options have been keyword arguments since 3.0,
so passing a positional Hash raises ArgumentError.

https://github.com/ruby/json/commit/effca27964
2026-09-09 06:21:57 +00:00
Benjamin Quorning 83185d33c4 [ruby/json] Update documentation to match json 3.0 API
json 3.0 changed `JSON.parse` to take keyword arguments instead of a
positional opts Hash, so some of the documented usage would now raise
`ArgumentError`. I have updated all such examples to use kwargs instead.

Also align documented output with what is actually produced with the
current parser/generator on Ruby 4.0, plus a number of other minor
changes.

https://github.com/ruby/json/commit/8bdd5179df
2026-09-08 15:56:53 +00:00
Koichi ITO 847c5ce1ac [ruby/json] Fix JSON.load_file and JSON.load_file! to load on Ruby 2.7.0 through 2.7.2
Since https://github.com/ruby/json/commit/ebf0f29, `load_file` and `load_file!` forward their arguments to
`parse` and `parse!` with `...` after a leading parameter. Ruby 2.7 accepts `...` only on its own;
a leading parameter before it was added in Ruby 3.0 and reached the 2.7 series in 2.7.3, so on Ruby 2.7.0
through 2.7.2 requiring json 3.0 raises a `SyntaxError` at `lib/json/common.rb`, while the gemspec still allows
Ruby 2.7 as a whole.

`parse` and `parse!` take keyword arguments only, so forwarding `**options` passes exactly what `...` passed,
on every Ruby the gem supports.

A `method_missing` helper in the parser tests used the same form; it takes an anonymous splat now,
so the test suite itself loads on those versions.

Checked with `ruby -c` on Ruby 2.7.0, 2.7.2, 2.7.3, and 3.0.7, and with the test suite on Ruby 2.7.2 and 3.0.7.

https://github.com/ruby/json/commit/29dad14674
2026-09-08 10:42:56 +00:00
Jean Boussier 78963e69a3 [ruby/json] Release 3.0.1
https://github.com/ruby/json/commit/c557a62719
2026-09-08 07:09:17 +00:00
Jean Boussier d98d7978dc [ruby/json] Restore the limit positional argument of JSON.dump
I really wanted to get rid of this because the argument parsing is
awful and costly.

But `rdoc` has been using this positional argument for decades,
and while the fix has been merged, having to upgrade to the latest
rdoc is a bit too disruptive.

https://github.com/ruby/json/commit/566bd7c108
2026-09-08 07:06:44 +00:00
Jean Boussier 3ade997abe [ruby/json] Release 3.0.0
https://github.com/ruby/json/commit/9427d36671
2026-09-07 06:57:12 +00:00
Elankumaran Srinivasan 4219a1aa68 [ruby/json] Fix parser silently accepting a lone trailing surrogate in string values
The C parser guards leading-first surrogate pairs but silently accepts
a lone trailing surrogate, encoding U+DC00..U+DFFF as three UTF-8 bytes
into the output buffer. The returned Ruby String is tagged UTF-8 but
fails valid_encoding? and raises misleading errors from downstream
String operations (upcase, split, regex, encode, JSON.generate).

Add a symmetric branch alongside the leading-surrogate check to raise
JSON::ParserError at the parse boundary. Extend test_invalid_surogates
with the new cases and move the three JSONTestSuite fixtures that this
fix newly rejects from INVALID_ENCODING_TESTS into UNDEFINED_FAILING,
closing the CRuby/JRuby parser parity gap documented in the file.

https://github.com/ruby/json/commit/82bf6bedcf
2026-09-07 06:53:10 +00:00
Shizuo FujitaandClaude Opus 5 5985f8bb18 [ruby/json] Fix SEGV when as_json returns a non-String for an invalid symbol
In strict mode, a Symbol whose name is not UTF-8 compatible was passed to
generate_json_string, which handed the as_json result to
raw_generate_json_string without checking its type. A non-String result was
then read as a String, segfaulting the process.

Route strict symbols through the T_STRING case of generate_json_general so
they reuse its as_json handling. That re-dispatches the result by type, and
its as_json_called flag stops a symbol returned by as_json from recursing.

https://github.com/ruby/json/commit/2d73e6bdfe

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 07:35:48 +00:00
Ojus ChughandJean Boussier 065a5592d2 [ruby/json] Add JSON::ParserError#json_path
(https://github.com/ruby/json/pull/1062)

Add JSON::ParserError#json_path

https://github.com/ruby/json/commit/9ae76bdd3d

Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2026-08-24 15:04:10 +00:00
Jean Boussier f51515f39a [ruby/json] Relase 3.0.0.rc1
https://github.com/ruby/json/commit/4f89162e8b
2026-08-11 08:12:52 +00:00
Jean Boussier 0e63aec18f [ruby/json] Prepare 3.x release notes
https://github.com/ruby/json/commit/7924498395
2026-08-11 08:12:52 +00:00
Jean Boussier fe6bb69c82 [ruby/json] Get rid of JSON::JSON_LOADED
https://github.com/ruby/json/commit/4816cab109
2026-08-11 08:12:52 +00:00
Jean Boussier ac60d4ae4d [ruby/json] Make generator options strict
https://github.com/ruby/json/commit/a8d7f6da6b
2026-08-11 08:12:51 +00:00