diff --git a/src/rules.ts b/src/rules.ts index c9bc07c5d6..cdbbeadb93 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -395,7 +395,7 @@ const _inlineLabel = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?! const link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/) .replace('label', _inlineLabel) - .replace('href', /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/) + .replace('href', /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/) .replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/) .getRegex(); diff --git a/test/specs/redos/quadratic_link_empty_href.cjs b/test/specs/redos/quadratic_link_empty_href.cjs new file mode 100644 index 0000000000..17b3ddf04b --- /dev/null +++ b/test/specs/redos/quadratic_link_empty_href.cjs @@ -0,0 +1,4 @@ +module.exports = { + markdown: '[](' + ' '.repeat(50000), + html: '
[](' + ' '.repeat(50000) + '
', +};