Skip to content

Commit

Permalink
Merge pull request #1578 from contentstack/fix/staging
Browse files Browse the repository at this point in the history
fixed regex dos issue in variants message
  • Loading branch information
cs-raj authored Sep 23, 2024
2 parents 2a4ebf5 + e22db80 commit c518bce
Show file tree
Hide file tree
Showing 3 changed files with 245 additions and 236 deletions.
73 changes: 39 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/contentstack-variants/src/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function $t(msg: string, args: Record<string, string>): string {

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

return msg;
Expand Down
Loading

0 comments on commit c518bce

Please sign in to comment.