Skip to content

Commit cab93cb

Browse files
committed
Fix escaping of special chars in Flex literal regex
Correct the regex and replacement used when escaping Flex double-quoted literals. The character class was adjusted to properly include braces and the dollar sign, and the replacement was simplified to use '\\$&' (instead of string concatenation) so metacharacters are reliably escaped when converting "..." literals into escaped regex form.
1 parent 9f30ca1 commit cab93cb

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

client/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ function renderFlexTestRuleHtml(initialPattern: string): string {
13611361
var p = pat;
13621362
// Handle Flex double-quoted literals: "..." -> escaped literal
13631363
p = p.replace(/"([^"]*)"/g, function(_, s) {
1364-
return s.replace(/[.*+?^${}()|\\[\\]\\\\]/g, '\\\\' + '$&');
1364+
return s.replace(/[.*+?^{}$()|\\[\\]\\\\]/g, '\\\\$&');
13651365
});
13661366
// Replace {abbrev} references with a generic placeholder (word chars)
13671367
p = p.replace(/[{]([a-zA-Z_][a-zA-Z0-9_]*)[}]/g, '[a-zA-Z0-9_]+');

0 commit comments

Comments
 (0)