mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update helpers.inlineCommentRe to fix an instance of "Polynomial regular expression used on uncontrolled data".
This commit is contained in:
parent
1c89dd5776
commit
f46ee0732f
3 changed files with 32 additions and 24 deletions
|
@ -346,9 +346,14 @@ function getEnabledRulesPerLineNumber(
|
|||
input.forEach((line, lineIndex) => {
|
||||
if (!noInlineConfig) {
|
||||
let match = null;
|
||||
while ((match = helpers.inlineCommentRe.exec(line))) {
|
||||
const action = (match[1] || match[3]).toUpperCase();
|
||||
const parameter = match[2] || match[4];
|
||||
while ((match = helpers.inlineCommentStartRe.exec(line))) {
|
||||
const action = match[2].toUpperCase();
|
||||
const startIndex = match.index + match[1].length;
|
||||
const endIndex = line.indexOf("-->", startIndex);
|
||||
if (endIndex === -1) {
|
||||
break;
|
||||
}
|
||||
const parameter = line.slice(startIndex, endIndex);
|
||||
forEachMatch(action, parameter, lineIndex + 1);
|
||||
}
|
||||
}
|
||||
|
@ -375,9 +380,8 @@ function getEnabledRulesPerLineNumber(
|
|||
function applyEnableDisable(action, parameter, state) {
|
||||
state = { ...state };
|
||||
const enabled = (action.startsWith("ENABLE"));
|
||||
const items = parameter ?
|
||||
parameter.trim().toUpperCase().split(/\s+/) :
|
||||
allRuleNames;
|
||||
const trimmed = parameter && parameter.trim();
|
||||
const items = trimmed ? trimmed.toUpperCase().split(/\s+/) : allRuleNames;
|
||||
items.forEach((nameUpper) => {
|
||||
(aliasToRuleNames[nameUpper] || []).forEach((ruleName) => {
|
||||
state[ruleName] = enabled;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue