Skip to content

Commit

Permalink
All invalid unicode when mimicking the JSON gem
Browse files Browse the repository at this point in the history
  • Loading branch information
ohler55 committed Sep 16, 2021
1 parent fab1294 commit 191df0b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 3.13.7 - 2021-09-16

- The JSON gem allows invalid unicode so Oj, when mimicing JSON now
allows it as well. Use `:allow_invalid_unicode` to change that.

## 3.13.6 - 2021-09-11

- Fixed unicode UTF 8 parsing in string values.
Expand Down
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ see the See [{file:CHANGELOG.md}](CHANGELOG.md) file. In this file are
the steps to take to aid in keeping things rolling after updating to
the latest version.

## 3.13.7

The default for JSON when mimicked by Oj is now to set
`:allow_invalid_unicode`. To change that behavior JSON.load, set that
option to false.

## 3.13.x

This release included a new cache that performs better than the
Expand Down
9 changes: 4 additions & 5 deletions ext/oj/mimic_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ static VALUE mimic_parse_core(int argc, VALUE *argv, VALUE self, bool bang) {
pi.options = oj_default_options;
pi.options.auto_define = No;
pi.options.quirks_mode = Yes;
pi.options.allow_invalid = No;
pi.options.allow_invalid = Yes;
pi.options.empty_string = No;
pi.options.create_ok = No;
pi.options.allow_nan = (bang ? Yes : No);
Expand Down Expand Up @@ -573,8 +573,7 @@ static VALUE mimic_parse_core(int argc, VALUE *argv, VALUE self, bool bang) {
}
}
if (oj_hash_has_key(ropts, oj_decimal_class_sym)) {
pi.options.compat_bigdec = (oj_bigdecimal_class ==
rb_hash_lookup(ropts, oj_decimal_class_sym));
pi.options.compat_bigdec = (oj_bigdecimal_class == rb_hash_lookup(ropts, oj_decimal_class_sym));
}
v = rb_hash_lookup(ropts, oj_max_nesting_sym);
if (Qtrue == v) {
Expand Down Expand Up @@ -682,7 +681,7 @@ static VALUE mimic_set_create_id(VALUE self, VALUE id) {
*/
static VALUE mimic_create_id(VALUE self) {
if (NULL != oj_default_options.create_id) {
return rb_utf8_str_new(oj_default_options.create_id, oj_default_options.create_id_len);
return rb_utf8_str_new(oj_default_options.create_id, oj_default_options.create_id_len);
}
return rb_str_new_cstr(oj_json_class);
}
Expand All @@ -706,7 +705,7 @@ static struct _options mimic_object_to_json_options = {0, // indent
No, // empty_string
Yes, // allow_gc
Yes, // quirks_mode
No, // allow_invalid
Yes, // allow_invalid
No, // create_ok
No, // allow_nan
No, // trace
Expand Down
2 changes: 1 addition & 1 deletion lib/oj/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

module Oj
# Current version of the module.
VERSION = '3.13.6'
VERSION = '3.13.7'
end

0 comments on commit 191df0b

Please sign in to comment.