Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behaviour change between 2.5.1 and 2.6.0 #527

Open
stac47 opened this issue Jun 26, 2023 · 0 comments
Open

Behaviour change between 2.5.1 and 2.6.0 #527

stac47 opened this issue Jun 26, 2023 · 0 comments

Comments

@stac47
Copy link

stac47 commented Jun 26, 2023

Hello,

I just wanted to report that there was a slight behaviour change between those two versions. If we take the following:

 require "json"
 wrong_utf8 = "\x12\x34TESTING\xfe".force_encoding('BINARY')
 JSON.generate(wrong_utf8)

With json 2.5.1:

% bundle exec ruby reproducer.rb
/Users/stac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/json-2.5.1/lib/json/common.rb:312:in `generate': "\xFE" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
        from /Users/stac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/json-2.5.1/lib/json/common.rb:312:in `generate'
        from reproducer.rb:3:in `<main>'

With json 2.6.0:

% bundle exec ruby reproducer.rb
/Users/stac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/json-2.6.0/lib/json/common.rb:312:in `generate': partial character in source, but hit end (JSON::GeneratorError)
        from /Users/stac/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/json-2.6.0/lib/json/common.rb:312:in `generate'
        from reproducer.rb:3:in `<main>'

This has also been tested with ruby 2.7.8 and 3.2.2.

Reading the changelog, I was not expecting such a change.

Regards,

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

No branches or pull requests

1 participant