mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Replace helpers.linkRe with helpers.forEachLink to fix "Polynomial regular expression used on uncontrolled data" and to better support link syntax.
This commit is contained in:
parent
861443c740
commit
7a53caa7fb
4 changed files with 458 additions and 28 deletions
|
|
@ -3,7 +3,7 @@
|
|||
"use strict";
|
||||
|
||||
const { addErrorDetailIf, bareUrlRe, escapeForRegExp, forEachLine,
|
||||
overlapsAnyRange, linkRe, linkReferenceRe } = require("../helpers");
|
||||
forEachLink, overlapsAnyRange, linkReferenceRe } = require("../helpers");
|
||||
const { codeBlockAndSpanRanges, lineMetadata } = require("./cache");
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -25,14 +25,13 @@ module.exports = {
|
|||
while ((match = bareUrlRe.exec(line)) !== null) {
|
||||
exclusions.push([ lineIndex, match.index, match[0].length ]);
|
||||
}
|
||||
while ((match = linkRe.exec(line)) !== null) {
|
||||
const [ , text, destination ] = match;
|
||||
forEachLink(line, (index, _, text, destination) => {
|
||||
if (destination) {
|
||||
exclusions.push(
|
||||
[ lineIndex, match.index + text.length, destination.length ]
|
||||
[ lineIndex, index + text.length, destination.length ]
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (!includeCodeBlocks) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue