Skip to content
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## Unreleased

### 🐛 Fixed

* 🐛 Keep a literal backslash before a space in link and image destinations, so the space ends the destination instead of making the link fail.

## 4.3.0 - 2026-11-10

This release fixes two quadratic-time parsing paths that let crafted input stall rendering for minutes (security),
Expand Down
3 changes: 2 additions & 1 deletion markdown_it/helpers/parse_link_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def parseLinkDestination(string: str, pos: int, maximum: int) -> _Result:

if code == 0x5C and pos + 1 < maximum:
if charCodeAt(string, pos + 1) == 0x20:
break
pos += 1
continue
pos += 2
continue

Expand Down
23 changes: 23 additions & 0 deletions tests/test_port/fixtures/commonmark_extras.md
Original file line number Diff line number Diff line change
Expand Up @@ -880,3 +880,26 @@ foo
<p>foo</p>
<!bar baz>
.

Backslash before a space inside a link destination (CommonMark 0.31.2 6.3) is a literal backslash, and the space ends the destination.
.
[a](/url\ )
.
<p><a href="/url%5C">a</a></p>
.

Backslash before a space in a link destination, followed by a title.
.
[a](/url\ "title")
.
<p><a href="/url%5C" title="title">a</a></p>
.

Backslash before a space in a reference destination.
.
[a]: /url\ "title"

[a]
.
<p><a href="/url%5C" title="title">a</a></p>
.