Fix an instance of "Polynomial regular expression used on uncontrolled data".

This commit is contained in:
David Anson 2022-01-21 21:51:36 -08:00
parent b6121341b9
commit cb5eebb145
2 changed files with 5 additions and 2 deletions

View file

@ -5,6 +5,8 @@
const { addErrorContext, filterTokens, headingStyleFor } =
require("../helpers");
const closedAtxRe = /^(#+)([ \t]+)([^ \t]|[^ \t].*[^ \t])([ \t]+)(#+)(\s*)$/;
module.exports = {
"names": [ "MD021", "no-multiple-space-closed-atx" ],
"description": "Multiple spaces inside hashes on closed atx style heading",
@ -13,7 +15,7 @@ module.exports = {
filterTokens(params, "heading_open", (token) => {
if (headingStyleFor(token) === "atx_closed") {
const { line, lineNumber } = token;
const match = /^(#+)([ \t]+)([^#]+?)([ \t]+)(#+)(\s*)$/.exec(line);
const match = closedAtxRe.exec(line);
if (match) {
const [
,