Computed constants output misrepresents source locations if non-ASCII characters are present in the source
- Dominant language
- C++
- Stars
- 664
- Forks
- 30
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 11
Description
If the script that jsir_gen is acting upon contains non-ASCII characters such as Cyrillic script (even in comments), it mixes up byte-position vs character-position and outputs wrong segments of the script. The issue appears to be that `JsPosition` when fetching from the JSON returns character position, but then `original_source.substr` on lines 75-77 of `jsir_gen_lib.cc` uses `absl::string_view.substr` which operates on bytes.
For example, if you run `jsir_gen` on the script:
```javascript
// тестовые символы кириллицы
let c = atob("SGVsbG8sIHdvcmxkIQ==");
```
It will output:
```
// Dataflow etc omitted
================================================================
Computed constants:
================================================================
From [39, 67): `риллицы
let c = atob` -> `Hello, world!`
================================================================
```
In between the \` \` it has mistakenly captured the newlines and the end of the comment due to the mixup instead of the actual function call.
Contributor guide
Assessment
This issue has not been assessed yet.