Commit graph

7 commits

Author SHA1 Message Date
Earlopain
970813d982 [ruby/prism] Fix parser translator during string escaping with invalid utf-8
Instead, prefer `scan_byte` over `get_byte` since that already returns the byte as an integer, sidestepping conversion issues.

Fixes https://github.com/ruby/prism/issues/3582

7f3008b2b5
2025-06-11 18:07:43 +00:00
Kevin Newton
050ffab82b [ruby/prism] Polyfill Kernel#warn category parameter
d85c72a1b9
2025-03-19 21:03:18 +00:00
Earlopain
a679597547 [ruby/prism] Fix parser translator crash for certain octal escapes
`Integer#chr` performs some validation that we don't want/need. Octal escapes can go above 255, where it will then raise trying to convert.

`append_as_bytes` actually allows to pass a number, so we can just skip that call.
Although, on older rubies of course we still need to handle this in the polyfill.
I don't really like using `pack` but don't know of another way to do so.

For the utf-8 escapes, this is not an issue. Invalid utf-8 in these is simply a syntax error.

161c606b1f
2025-03-18 13:36:53 -04:00
Earlopain
705bd6fadb [ruby/prism] Fix parser translator when unescaping invalid utf8
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

e31e94a775
2025-03-18 13:36:53 -04:00
Kevin Newton
d4a6d0c177 [ruby/prism] Prism::Location#adjoin
a298db68e3
2024-05-03 19:14:03 +00:00
Kevin Newton
b6489e9f62 [ruby/prism] Remove need for Natalie patches
7fc7e13476
2024-04-25 18:00:09 +00:00
Ufuk Kayserilioglu
8d191a9f57 [ruby/prism] Move polyfill to separate file to type-check it independently.
2a583b041b
2024-03-06 21:37:53 +00:00