mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
fix: reject a link destination in angle brackets with an unescaped < or > (#4206)
This commit is contained in:
+2
-2
@@ -163,7 +163,7 @@ const lheadingGfm = edit(lheadingCore)
|
||||
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
|
||||
const blockText = /^[^\n]+/;
|
||||
const _blockLabel = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/;
|
||||
const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/)
|
||||
const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<(?:\\.|[^\n<>\\])*>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/)
|
||||
.replace('label', _blockLabel)
|
||||
// An escaped delimiter is part of the title, so a backslash must consume the
|
||||
// next character. An optional closer (`\"?`) lets that character backtrack
|
||||
@@ -488,7 +488,7 @@ const _inlineLabel = edit(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\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('href', /<(?:\\.|[^\n<>\\])*>|(?!<)[^ \t\n\x00-\x1f]+|(?=\))/)
|
||||
// Same as the definition title: the escaped character is not the closer.
|
||||
.replace('title', /"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/)
|
||||
.getRegex();
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<p>[a](<b<c>)</p>
|
||||
<p>[a](<b>c>)</p>
|
||||
<p>[a](<b>>)</p>
|
||||
<p></p>
|
||||
<p><a href="b%3Cc" title="t">a</a></p>
|
||||
<p>[r]: <x<y></p>
|
||||
<p>[r]</p>
|
||||
@@ -0,0 +1,13 @@
|
||||
[a](<b<c>)
|
||||
|
||||
[a](<b>c>)
|
||||
|
||||
[a](<b>>)
|
||||
|
||||

|
||||
|
||||
[a](<b\<c> "t")
|
||||
|
||||
[r]: <x<y>
|
||||
|
||||
[r]
|
||||
Reference in New Issue
Block a user