Reimplement helpers.isBlankLine to fix an instance of "Polynomial regular expression used on uncontrolled data".

This commit is contained in:
David Anson 2022-02-11 21:54:43 -08:00
parent b9474e84a3
commit 1c89dd5776
3 changed files with 76 additions and 27 deletions

View file

@ -226,7 +226,7 @@ bar`
});
test("isBlankLine", (t) => {
t.plan(29);
t.plan(33);
const blankLines = [
null,
"",
@ -248,7 +248,9 @@ test("isBlankLine", (t) => {
"<!--",
" <!-- text",
"text --> ",
"-->"
"-->",
"text --> <!--text--> <!--text--> <!-- text",
"text --> --> <!--text--> <!--text--> <!-- <!-- text"
];
blankLines.forEach((line) => t.true(helpers.isBlankLine(line), line || ""));
const nonBlankLines = [
@ -259,7 +261,9 @@ test("isBlankLine", (t) => {
"<!--text--> text",
"text <!--text-->",
"text <!--",
"--> text"
"--> text",
"text --> <!--text--> text <!--text--> <!-- text",
"text --> --> <!--text--> text <!--text--> <!-- <!-- text"
];
nonBlankLines.forEach((line) => t.true(!helpers.isBlankLine(line), line));
});