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

Always dup argument to preserve original encoding for force_encoding #537

Merged

Conversation

aeroastro
Copy link
Contributor

This fixes #529.

In order to avoid changing original encoding,
this patch always dups argument for ASCII-8BIT encoding.

I have also added a test test_argument_encoding_for_binary.
The structure is following test_argument_encoding.

Considering the following facts, IMHO, I believe this patch meets the original intention of this gem.

  • JSON::Pure::Parser.new(str) does not change the encoding of original argument for ASCII-8BIT
  • There already exists a test to guarantee that the encoding of argument is not changed for non ASCII-8BIT encodings.

@Dani-beef

This comment was marked as off-topic.

@byroot byroot force-pushed the feature/stop-changing-original-encoding branch from 9db2b4e to 1d99922 Compare October 17, 2024 15:28
@byroot byroot force-pushed the feature/stop-changing-original-encoding branch from 1d99922 to db9a489 Compare October 17, 2024 16:21
@byroot
Copy link
Member

byroot commented Oct 17, 2024

Thanks. I rebased your PR and also added the Java version of the fix.

@byroot byroot merged commit e272c89 into ruby:master Oct 17, 2024
73 checks passed
@aeroastro aeroastro deleted the feature/stop-changing-original-encoding branch October 21, 2024 05:22
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.

JSON.parse Alters Encoding of Passed String Unexpectedly
3 participants