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

bugfix json/pure mixing escaped with literal unicode raises Encoding::CompatibilityError #483

Merged
merged 2 commits into from Jun 13, 2022

Conversation

notEthan
Copy link
Contributor

@notEthan notEthan commented Oct 20, 2021

mixing \u-escaped unicode with literal unicode characters, like so:

JSON::Pure::Parser.new(%(["\\u00e9é"])).parse

results in this error:

.../gems/json-2.3.1/lib/json/pure/parser.rb:194:in `rescue in parse_string': Caught Encoding::CompatibilityError at ']': incompatible character encodings: UTF-8 and ASCII-8BIT (JSON::ParserError)

which comes from here:

.../gems/json-2.3.1/lib/json/pure/parser.rb:167:in `gsub': incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)

I think that forcing the encoding of the gsub result back to ASCII_8BIT is a good fix for this since the StringScanner string is forced to ASCII_8BIT. I can't be entirely certain though; the handling of encoding in this parser is a bit beyond me.

@notEthan
Copy link
Contributor Author

this would fix #232 (opened 7 years ago)

@davishmcclurg
Copy link

@notEthan haha looks like you beat me to it: #484

Did you run into this in https://github.com/json-schema-org/JSON-Schema-Test-Suite/ as well?

At least we came up with the same fix :)

@notEthan
Copy link
Contributor Author

remarkable, the very same. my implementation is here: https://github.com/notEthan/jsi . I've just merged (but not yet released) support for validating on its own. it would be cool to have a chat someplace if you'd be interested.

@davishmcclurg
Copy link

it would be cool to have a chat someplace if you'd be interested.

That sounds good to me. Feel free to send me an email (davishmcclurg@gmail.com) and we can figure something out.

@sjahu
Copy link

sjahu commented Feb 1, 2022

I also ran into this bug and came up with the same fix as you two. It would be great to get this merged 🤞

@sjahu
Copy link

sjahu commented Feb 1, 2022

hey @hsbt! sorry for the noise but if you get a chance could this PR be considered?

@hsbt
Copy link
Collaborator

hsbt commented Feb 7, 2022

@notEthan Can you rebase this from the master branch? I'm not sure why this pr didn't invoke our CI.

@notEthan
Copy link
Contributor Author

notEthan commented Feb 9, 2022

rebased. the CI doesn't run because I am a first-time contributor. I see the message:

1 workflow awaiting approval
First-time contributors need a maintainer to approve running workflows. Learn more.

@hsbt
Copy link
Collaborator

hsbt commented Feb 9, 2022

@notEthan Thanks, I approved it now.

@notEthan
Copy link
Contributor Author

@hsbt @flori can this be merged?

@hsbt hsbt merged commit 415953c into flori:master Jun 13, 2022
davishmcclurg added a commit to davishmcclurg/json_schemer that referenced this pull request Jun 7, 2023
Truffleruby's version of json/pure has a bug that's triggered by these
files. It's been fixed but the fix isn't in Truffleruby yet:

- flori/json#483
- flori/json#484

This skips the files when the error is raised and drops them before
checking fixtures.
davishmcclurg added a commit to davishmcclurg/json_schemer that referenced this pull request Jun 7, 2023
Truffleruby's version of json/pure has a bug that's triggered by these
files. It's been fixed but the fix isn't in Truffleruby yet:

- flori/json#483
- flori/json#484

This skips the files when the error is raised and drops them before
checking fixtures.
davishmcclurg added a commit to davishmcclurg/json_schemer that referenced this pull request Nov 28, 2023
The [fix](flori/json#483) must've made it fully
into Truffleruby now, because this isn't failing anymore.
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.

None yet

4 participants