Open secext2022 opened 4 months ago
Hello @marvinhagemeister Could you please confirm if the issue should be resolved by allowing non-ASCII characters?
Deno should never panic, so yes.
Hi @marvinhagemeister,
I've investigated this issue and found that in the code snippet that I attached below is attempting to extract a substring from self.text_str() based on the start and end positions specified in a SourceRange. The panic occurs because the code is slicing the string at byte indices that are not valid UTF-8 character boundaries. In Rust, strings are UTF-8 encoded, and incorrect slicing can cause panics. This issue originates from the Rust external library dprint-swc-ext-0.16.0.
My suggestions are as follows:
Replace the range_text Method: The problematic code is being called from the deno-ast repository inside the diagnostics.rs file. I suggest replacing the range_text method with a new method that correctly handles non-ASCII characters.
Or Add Error Messages: Introduce error messages indicating that non-ASCII characters are not supported to prevent Deno from panicking.
Please let me know if you have any other ideas or suggestions.
looping in @dsherret who has more context on dprint.
Version: Deno 1.43.4
reproduce step:
source code
t.ts
:run command and crash log: