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

@ -2750,6 +2750,7 @@ module.exports = {
// @ts-check // @ts-check
var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, filterTokens = _a.filterTokens, headingStyleFor = _a.headingStyleFor; var _a = __webpack_require__(/*! ../helpers */ "../helpers/helpers.js"), addErrorContext = _a.addErrorContext, filterTokens = _a.filterTokens, headingStyleFor = _a.headingStyleFor;
var closedAtxRe = /^(#+)([ \t]+)([^ \t]|[^ \t].*[^ \t])([ \t]+)(#+)(\s*)$/;
module.exports = { module.exports = {
"names": ["MD021", "no-multiple-space-closed-atx"], "names": ["MD021", "no-multiple-space-closed-atx"],
"description": "Multiple spaces inside hashes on closed atx style heading", "description": "Multiple spaces inside hashes on closed atx style heading",
@ -2758,7 +2759,7 @@ module.exports = {
filterTokens(params, "heading_open", function (token) { filterTokens(params, "heading_open", function (token) {
if (headingStyleFor(token) === "atx_closed") { if (headingStyleFor(token) === "atx_closed") {
var line = token.line, lineNumber = token.lineNumber; var line = token.line, lineNumber = token.lineNumber;
var match = /^(#+)([ \t]+)([^#]+?)([ \t]+)(#+)(\s*)$/.exec(line); var match = closedAtxRe.exec(line);
if (match) { if (match) {
var leftHash = match[1], leftSpaceLength = match[2]["length"], content = match[3], rightSpaceLength = match[4]["length"], rightHash = match[5], trailSpaceLength = match[6]["length"]; var leftHash = match[1], leftSpaceLength = match[2]["length"], content = match[3], rightSpaceLength = match[4]["length"], rightHash = match[5], trailSpaceLength = match[6]["length"];
var left = leftSpaceLength > 1; var left = leftSpaceLength > 1;

View file

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