Replace Array.push(...spread) in micromark helpers with Array.concat to avoid risk of stack overflow.

This commit is contained in:
David Anson 2023-09-04 22:02:39 -07:00
parent 07f403173c
commit a7dfa4bcbf
2 changed files with 7 additions and 7 deletions

View file

@ -107,7 +107,7 @@ function micromarkParseWithOffset(
// Create Token objects
const document = [];
const flatTokens = [];
let flatTokens = [];
let current = {
"children": document
};
@ -161,7 +161,9 @@ function micromarkParseWithOffset(
current.startLine - 1
);
current.children = tokens;
flatTokens.push(...tokens[flatTokensSymbol]);
// Avoid stack overflow of Array.push(...spread)
// eslint-disable-next-line unicorn/prefer-spread
flatTokens = flatTokens.concat(tokens[flatTokensSymbol]);
}
} else if (kind === "exit") {
if (type === "htmlFlow") {