diff options
author | Jean Boussier <[email protected]> | 2024-10-21 22:19:44 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-10-26 18:44:15 +0900 |
commit | fc9f0cb8c5ead74455370f2ae409bc4a6b1dedc0 (patch) | |
tree | f289961afc78ca5903e306e7d17cad870f3e9a46 /ext/json/parser/parser.rl | |
parent | 2c6e3bc71e12e12ad6949502e2b161171ca56840 (diff) |
[ruby/json] JSON.dump / String#to_json: raise on invalid encoding
This regressed since 2.7.2.
https://github.com/ruby/json/commit/35407d6635
Diffstat (limited to 'ext/json/parser/parser.rl')
-rw-r--r-- | ext/json/parser/parser.rl | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl index 6ebb2f6fac..73f81341ab 100644 --- a/ext/json/parser/parser.rl +++ b/ext/json/parser/parser.rl @@ -689,6 +689,9 @@ static VALUE convert_encoding(VALUE source) } if (encindex == binary_encindex) { + // For historical reason, we silently reinterpret binary strings as UTF-8 if it would work. + // TODO: Deprecate in 2.8.0 + // TODO: Remove in 3.0.0 return rb_enc_associate_index(rb_str_dup(source), utf8_encindex); } |