Skip to content

Commit

Permalink
fix: string literals generator must generate escaped strings
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-trunov committed Dec 28, 2024
1 parent ca85f4e commit 875150c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/test/utils/expression/randomAst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ export function randomAstBoolean(): fc.Arbitrary<AstBoolean> {
}

export function randomAstString(): fc.Arbitrary<AstString> {
const escapeString = (s: string): string =>
s.replace("\\", "\\\\").replace('"', '\\"');

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High test

This replaces only the first occurrence of '"'.

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High test

This replaces only the first occurrence of "".

return dummyAstNode(
fc.record({
kind: fc.constant("string"),
value: fc.string(),
value: fc.string().map((s) => escapeString(s)),
}),
);
}
Expand Down

0 comments on commit 875150c

Please sign in to comment.