Skip to content

fix: Preserve Unicode escape sequences in transformation - #173

Open
zermelo-wisen wants to merge 1 commit into
mainfrom
fix/unicode-transform
Open

fix: Preserve Unicode escape sequences in transformation#173
zermelo-wisen wants to merge 1 commit into
mainfrom
fix/unicode-transform

Conversation

@zermelo-wisen

Copy link
Copy Markdown
Contributor

Fixes#172.

Ensures that Unicode escape sequences (e.g., "\u{1D306}") are correctly preserved during the code transformation process. This fix addresses an issue where certain escape sequences were incorrectly converted when parsing and regenerating code.

The fix gives raw: true option to the meriyahparse function in transform.ts.

consttree=parse(code,{source: url.toString(),next: true,loc: true,module: true,onComment: comments,raw: true,// Added this line});

This test, which would fail without the fix, is added to transform.test.ts.

it("transforms unicode correctly",()=>{constinput=`const a = "\\u{1D306}";\n`;// Ensure that "\u{1D306}" is not converted to "t̆".expect(transform(input,newURL("file:///foo"),[newIdentityHook()])).toBe(input);});

Ensure that Unicode escape sequences (e.g., "\u{1D306}") are correctly
preserved during the code transformation process. This fix addresses an
issue where certain escape sequences were incorrectly converted when
parsing and regenerating code, leading to unintended character
alterations.
Sign up for freeto 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.

Failing tests in gchq/CyberChef

2 participants

@zermelo-wisen@edisigci