From 4a46040434b5cd125fb42c89a1a6a3b00a149900 Mon Sep 17 00:00:00 2001 From: Crozzers Date: Mon, 29 May 2023 17:03:43 +0100 Subject: [PATCH] Update tests for new safe href regex --- lib/markdown2.py | 2 +- test/tm-cases/basic_safe_mode.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/markdown2.py b/lib/markdown2.py index 9f79ebce..48d9d4c6 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -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 and tags. diff --git a/test/tm-cases/basic_safe_mode.html b/test/tm-cases/basic_safe_mode.html index 95c00ad0..60051078 100644 --- a/test/tm-cases/basic_safe_mode.html +++ b/test/tm-cases/basic_safe_mode.html @@ -6,13 +6,13 @@

[HTML_REMOVED]alert(1)[HTML_REMOVED]

-

link1

+

link1

link2

-

link3

+

link3

-

link4 >[HTML_REMOVED]alert(1)[HTML_REMOVED]

+

link4 >[HTML_REMOVED]alert(1)[HTML_REMOVED]

link5