diff --git a/lib/markdown2.py b/lib/markdown2.py index 8b99ec3d..b82fa2f1 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -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: diff --git a/test/tm-cases/backslash_escape_empty_links.html b/test/tm-cases/backslash_escape_empty_links.html new file mode 100644 index 00000000..bffeaa51 --- /dev/null +++ b/test/tm-cases/backslash_escape_empty_links.html @@ -0,0 +1,4 @@ +
+ +one
+two