Skip to content

Reject non-ASCII BINARY strings during JSON generation - #1098

Merged
byroot merged 1 commit into
ruby:masterfrom
ydah:fix-binary-string-encoding
Oct 6, 2026
Merged

byroot merged 1 commit into
ruby:masterfrom
ydah:fix-binary-string-encoding

Conversation

@ydah

@ydah ydah commented Oct 6, 2026

Copy link
Copy Markdown
Member

Remove the BINARY-to-UTF-8 compatibility fallback and its outdated warning, completing the deprecation planned for 3.0 in #643.

require "json"

JSON.generate("日本".b)
# Before: warns about json 3.0 and returns "\"日本\""
# After: JSON::GeneratorError

JSON.generate("ascii".b)
# Still returns "\"ascii\""

Use the existing encoding error handling in C and Java, matching TruffleRuby. Cover binary strings as values and keys, while preserving ASCII-only input.

But, maybe now isn't the good time? WDYT?

@byroot
byroot merged commit 8bab92d into ruby:master Oct 6, 2026
42 checks passed
@ydah
ydah deleted the fix-binary-string-encoding branch October 6, 2026 12:10
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