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

Fix parser translator when unescaping invalid utf8 #3401

Merged

Conversation

Earlopain
Copy link
Contributor

  1. The string starts out as binary
  2. is appended, forcing it back into utf-8
  3. Some invalid byte sequences are tried to append

incompatible character encodings: UTF-8 and BINARY (ASCII-8BIT)

This makes use of my wish to use append_as_bytes. Unfortunatly that method is rather new so it needs a fallback.

It's for #2539. Since ruby-spec has some rather odd-looking code it runs into it.

Copy link
Collaborator

@kddnewton kddnewton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add this to the polyfills directory? We already have one for byteindex and one for unpack1, so may as well add another one here

1. The string starts out as binary
2. `ち` is appended, forcing it back into utf-8
3. Some invalid byte sequences are tried to append

> incompatible character encodings: UTF-8 and BINARY (ASCII-8BIT)

This makes use of my wish to use `append_as_bytes`. Unfortunatly that method is rather new
so it needs a fallback
@Earlopain Earlopain force-pushed the parser-translator-escaping-invalid-utf8 branch from 9999ef2 to e31e94a Compare January 12, 2025 19:09
@Earlopain
Copy link
Contributor Author

Works for me, didn't know that was a thing.

I really appreciate how fast you're getting to these. Thanks!

@kddnewton kddnewton merged commit 9074de8 into ruby:main Jan 13, 2025
57 checks passed
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