mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: avoid cubic backtracking on unicode whitespace in a link destination (#4106)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
c18a64fa5e
commit
0d2022025d
+1
-1
@@ -457,7 +457,7 @@ const _inlineLabel = edit(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?
|
||||
.replace('brackets', _inlineLabelBrackets)
|
||||
.getRegex();
|
||||
|
||||
const link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/)
|
||||
const link = edit(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/)
|
||||
.replace('label', _inlineLabel)
|
||||
.replace('href', /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/)
|
||||
.replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Same shape as quadratic_link_empty_href, with the ASCII space replaced by U+00A0.
|
||||
// The gap before a link destination used to be \s*, which also matches unicode
|
||||
// whitespace, while the destination class only excluded ASCII space, tab and newline.
|
||||
// A run of unicode whitespace could therefore be split between the two in n ways.
|
||||
module.exports = {
|
||||
markdown: '[](' + ' '.repeat(50000),
|
||||
html: `<p>[](${' '.repeat(50000)}</p>`,
|
||||
};
|
||||
Reference in New Issue
Block a user