From 668619d8b666f2b0438a7563973b15229def2129 Mon Sep 17 00:00:00 2001 From: Yader Velasquez Date: Tue, 1 Jun 2021 11:19:04 -0600 Subject: [PATCH] Validate protocol in url parser --- src/wiki/plugins/links/mdx/urlize.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/wiki/plugins/links/mdx/urlize.py b/src/wiki/plugins/links/mdx/urlize.py index 11691061..6e26a0f2 100644 --- a/src/wiki/plugins/links/mdx/urlize.py +++ b/src/wiki/plugins/links/mdx/urlize.py @@ -105,6 +105,10 @@ class UrlizePattern(markdown.inlinepatterns.Pattern): protocol = m.group("protocol") url = m.group("url") + + if not protocol: + return url + text = url begin_url = m.group("begin") @@ -133,11 +137,6 @@ class UrlizePattern(markdown.inlinepatterns.Pattern): ): return url - # If no supported protocol is specified, assume plaintext http - # and add it to the url. - if protocol == "": - url = "http://" + url - # Convenience link to distinguish external links more easily. icon = markdown.util.etree.Element("span") icon.set("class", "fa fa-external-link") -- 2.45.2