Skip to content

Commit 74be0a1

Browse files
Fix regex to avoid Polynomial time and fix security alert (#1587)
* Change regex to use non-greedy quantifier * Remove matching unlimited whitespaces * Trim white-spaces on loop tokens, remove lazy quantifier Co-authored-by: Sébastien Levert <[email protected]>
1 parent ef6133b commit 74be0a1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/mgt-element/src/utils/TemplateHelper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,12 @@ export class TemplateHelper {
241241
const childElement = loopChildren[i] as HTMLElement;
242242

243243
const loopExpression = childElement.dataset.for;
244-
const loopTokens = this.trimExpression(loopExpression).split(/\s+(in|of)\s+/i);
244+
const loopTokens = this.trimExpression(loopExpression).split(/\s(in|of)\s/i);
245245

246246
if (loopTokens.length === 3) {
247247
// don't really care what's in the middle at this point
248-
const itemName = loopTokens[0];
249-
const listKey = loopTokens[2];
248+
const itemName = loopTokens[0].trim();
249+
const listKey = loopTokens[2].trim();
250250

251251
const list = this.evalInContext(listKey, context);
252252
if (Array.isArray(list)) {

0 commit comments

Comments
 (0)