Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/mistune/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ def _parse_angle_link_href(src: str, pos: int) -> Union[Tuple[str, int], Tuple[N
c = src[pos]
if c == ">":
return src[start:pos], pos + 1
if c in "<\\\n\r\x00":
if c == "\\":
pos = min(pos + 2, len(src))
continue
if c in "<\n\r\x00":
return None, None
pos += 1
return None, None
8 changes: 8 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ def test_link_bracket_cache_cases(self):
for text, html in cases.items():
self.assertEqual(mistune.html(text).strip(), html)

def test_angle_link_escaped_backslash(self):
cases = {
r"[link](<foo\*bar>)": '<p><a href="foo*bar">link</a></p>',
"[x]: <a\\*b>\n\n[x]": '<p><a href="a*b">x</a></p>',
}
for text, html in cases.items():
self.assertEqual(mistune.html(text).strip(), html, text)

def test_allow_harmful_protocols(self):
renderer = mistune.HTMLRenderer(allow_harmful_protocols=True)
md = mistune.Markdown(renderer)
Expand Down
Loading