Skip to content

Commit

Permalink
Update tests for new safe href regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Crozzers committed May 29, 2023
1 parent 2be9f5b commit 4a46040
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ def _protect_url(self, url):
# Original Showdown code copyright (c) 2007 John Fraser
# Modifications and bugfixes (c) 2009 Dana Robinson
# Modifications and bugfixes (c) 2009-2014 Stack Exchange Inc.
_safe_href = re.compile(r'^((https?|ftp):\/\/|\/|\.|#)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)*[\]$]+$', re.I)
_safe_href = re.compile(r'^((https?|ftp):\/\/|\/|\.|#)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)*[\]$]*$', re.I)

def _do_links(self, text):
"""Turn Markdown link shortcuts into XHTML <a> and <img> tags.
Expand Down
6 changes: 3 additions & 3 deletions test/tm-cases/basic_safe_mode.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

<p>[HTML_REMOVED]alert(1)[HTML_REMOVED]</p>

<p><a href="http://example.com&quot;onclick=&quot;alert(1)">link1</a></p>
<p><a href="#">link1</a></p>

<p><a href="http://example.com" title="title&quot;onclick=&quot;alert(1)">link2</a></p>

<p><a href="http://example.com&gt;[HTML_REMOVED]alert(1)[HTML_REMOVED]">link3</a></p>
<p><a href="#">link3</a></p>

<p><a href="http://example.com&gt;[HTML_REMOVED]alert(1)[HTML_REMOVED]">link4 &gt;[HTML_REMOVED]alert(1)[HTML_REMOVED]</a></p>
<p><a href="#">link4 &gt;[HTML_REMOVED]alert(1)[HTML_REMOVED]</a></p>

<p><a href="#">link5</a></p>

Expand Down

0 comments on commit 4a46040

Please sign in to comment.