~netlandish/django-wiki

668619d8b666f2b0438a7563973b15229def2129 — Yader Velasquez 3 years ago e5b90bd
Validate protocol in url parser
1 files changed, 4 insertions(+), 5 deletions(-)

M src/wiki/plugins/links/mdx/urlize.py
M src/wiki/plugins/links/mdx/urlize.py => src/wiki/plugins/links/mdx/urlize.py +4 -5
@@ 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")