Skip to content

Commit a4163fd

Browse files
committed
fixed regex dos issue in variants message
1 parent 7b8a662 commit a4163fd

3 files changed

Lines changed: 245 additions & 236 deletions

File tree

package-lock.json

Lines changed: 39 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-variants/src/messages/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ function $t(msg: string, args: Record<string, string>): string {
5050

5151
for (const key of Object.keys(args)) {
5252
const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
53-
msg = msg.replace(new RegExp(`{${escapedKey}}`, 'g'), args[key] || escapedKey);
53+
const placeholder = `{${escapedKey}}`;
54+
msg = msg.split(placeholder).join(args[key]);
5455
}
5556

5657
return msg;

0 commit comments

Comments
 (0)