diff --git a/src/rules.ts b/src/rules.ts index 39fa7befbf..fd77781ea3 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -380,7 +380,7 @@ const tag = edit( const _inlineLabel = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/; -const link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\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('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/) diff --git a/test/specs/redos/cubic_link_title.cjs b/test/specs/redos/cubic_link_title.cjs new file mode 100644 index 0000000000..3066d0238a --- /dev/null +++ b/test/specs/redos/cubic_link_title.cjs @@ -0,0 +1,4 @@ +module.exports = { + markdown: 'a[b](c'.repeat(1000), + html: `

${'a[b](c'.repeat(1000)}

\n`, +};