You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oj is blindly serialising strings with invalid unicode sequences in them that I expected it would reject, when using Rails mode and setting ActiveSupport::JSON::Encoding.escape_html_entities_in_json = false. I'm happy for literal <, &, etc characters to appear in my JSON, but I do not want to emit JSON with invalid UTF-8 bytes!
Oj correctly mimics the JSON gem's default behaviour of throwing an exception here:
Oj is blindly serialising strings with invalid unicode sequences in them that I expected it would reject, when using Rails mode and setting
ActiveSupport::JSON::Encoding.escape_html_entities_in_json = false
. I'm happy for literal<
,&
, etc characters to appear in my JSON, but I do not want to emit JSON with invalid UTF-8 bytes!Oj correctly mimics the JSON gem's default behaviour of throwing an exception here:
So this is good. However, it's not correctly mimicking ActiveSupports' behaviour:
Oops! that last example should raise
JSON::GeneratorError
to be consistent with the rest, I think.The reason for this seems to be that this check for unicode correctness only seems to be being done for
RailsXEsc
mode, but notRailsEsc
mode:oj/ext/oj/dump.c
Line 825 in 0032fbb
Is this an accurate diagnosis? If you a) agree that this is a bug, and b) agree that that line is the right place to fix it, I'm happy to send a PR.
Thank you for your excellent work on Oj!
The text was updated successfully, but these errors were encountered: