Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Computed constants output misrepresents source locations if non-ASCII characters are present in the source #22

@enbyte

Description

@enbyte

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:

// тестовые символы кириллицы

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions