Skip to content

Reject incompatible RFC 8785 generation options - #1102

Merged
byroot merged 1 commit into
ruby:masterfrom
ydah:fix-rfc8785-incompatible-options
Oct 8, 2026
Merged

byroot merged 1 commit into
ruby:masterfrom
ydah:fix-rfc8785-incompatible-options

Conversation

@ydah

@ydah ydah commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Reject nonempty whitespace options and enabled ascii_only, script_safe, or allow_nan with ArgumentError when rfc8785 is enabled.

JSON.generate("é", rfc8785: true, ascii_only: true)
# Before: '"\u00e9"'
# After: ArgumentError

JSON.generate([Float::NAN, Float::INFINITY], rfc8785: true, allow_nan: true)
# Before: '[NaN,Infinity]'
# After: ArgumentError

Validate configuration and generation, including options changed through State setters. JSON.dump defaults allow_nan to false when rfc8785 is enabled.

JSON::Fragment remains supported for reusing canonicalized fragments. Its contents are inserted as is; callers must ensure they are canonical.

Addresses the incompatible-options TODO in #1091.

Comment thread ext/json/ext/generator/generator.c Outdated
@ydah
ydah force-pushed the fix-rfc8785-incompatible-options branch from ae2a5af to 5ebb52f Compare October 8, 2026 08:59
@ydah
ydah force-pushed the fix-rfc8785-incompatible-options branch from 5ebb52f to e37760a Compare October 8, 2026 09:03
@byroot
byroot merged commit 49e8df0 into ruby:master Oct 8, 2026
42 checks passed
@ydah
ydah deleted the fix-rfc8785-incompatible-options branch October 8, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants