mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-24 01:40:13 +01:00
Replace helpers.urlRe with helpers.urlFe to address "innefficient regular expression" CodeQL alert, introduce function expressions as an alternative, test more inputs.
This commit is contained in:
parent
485c63c579
commit
8d6e0b5419
5 changed files with 277 additions and 35 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, filterTokens, urlRe, withinAnyRange } =
|
||||
const { addErrorContext, filterTokens, funcExpExec, urlFe, withinAnyRange } =
|
||||
require("../helpers");
|
||||
const { codeBlockAndSpanRanges, htmlElementRanges, referenceLinkImageData } =
|
||||
require("./cache");
|
||||
|
|
@ -34,8 +34,9 @@ module.exports = {
|
|||
while ((match = htmlLinkRe.exec(line)) !== null) {
|
||||
lineExclusions.push([ lineIndex, match.index, match[0].length ]);
|
||||
}
|
||||
while ((match = urlRe.exec(line)) !== null) {
|
||||
while ((match = funcExpExec(urlFe, line)) !== null) {
|
||||
const [ bareUrl ] = match;
|
||||
// @ts-ignore
|
||||
const matchIndex = match.index;
|
||||
const bareUrlLength = bareUrl.length;
|
||||
const prefix = line.slice(0, matchIndex);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue