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
4 changes: 4 additions & 0 deletions lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,10 @@ def _protect_url(self, url: str) -> str:
and then hashes the now "safe" URL to prevent other safety mechanisms from tampering
with it (eg: escaping "&" in URL parameters)
'''
if not url:
# ignore links with empty URLs. Don't bother putting a hash there because then we'll have
# `"''"": "md5-..."` as an entry in the escape table, and that will cause havok
return url
data_url = self._data_url_re.match(url)
charset = None
if data_url is not None:
Expand Down
4 changes: 4 additions & 0 deletions test/tm-cases/backslash_escape_empty_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<p><a href="">link</a></p>

<p>one<br />
two</p>
1 change: 1 addition & 0 deletions test/tm-cases/backslash_escape_empty_links.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"extras": {"breaks": {"on_backslash": True}}}
4 changes: 4 additions & 0 deletions test/tm-cases/backslash_escape_empty_links.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[link]()

one\
two