Skip to content

Commit 217768f

Browse files
Demos test helper: fix regular expression injection (#32106) (#32115)
Signed-off-by: EugeniyKiyashko <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 8a60957 commit 217768f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

apps/demos/utils/visual-tests/matrix-test-helper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ function shouldRunTestExplicitlyInternal(framework, product, demo) {
4747
}
4848

4949
function patternGroupFromValues(product, demo, framework) {
50-
const wrap = (x) => RegExp(x || '.*', 'i');
50+
const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\-]/g, '\\$&');
51+
const wrap = (x) => RegExp(x ? escapeRegExp(x) : '.*', 'i');
5152
return {
5253
product: wrap(product),
5354
demo: wrap(demo),

0 commit comments

Comments
 (0)