Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
markdown: Replace hyperlink requirement with urllib.parse.
Anders Kaseorgdfab09b17d07
diff --git a/requirements/common.in b/requirements/common.inindex 9a5053c6199..f523022a30a 100644--- a/requirements/common.in+++ b/requirements/common.in@@ -18,7 +18,6 @@ Jinja2Markdownimportlib-metadata;python_version<"3.8" # for MarkdownPygments-hyperlinkjsx-lexer# Needed for manage.pydiff --git a/requirements/dev.txt b/requirements/dev.txtindex aa98b126a3d..c4adf38d6e5 100644--- a/requirements/dev.txt+++ b/requirements/dev.txt@@ -368,7 +368,7 @@ hyperframe==3.2.0 \hyperlink==19.0.0 \--hash=sha256:4288e34705da077fada1111a24a0aa08bb1e76699c9ce49876af722441845654 \--hash=sha256:ab4a308feb039b04f855a020a6eda3b18ca5a68e6d8f8c899cbe9e653721d04f \- # via -r requirements/common.in, twisted+ # via twistedidna==2.8 \--hash=sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407 \--hash=sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c \diff --git a/requirements/prod.txt b/requirements/prod.txtindex 10f9daf82b9..6bebc8a3522 100644--- a/requirements/prod.txt+++ b/requirements/prod.txt@@ -257,14 +257,10 @@ hyperframe==3.2.0 \--hash=sha256:05f0e063e117c16fcdd13c12c93a4424a2c40668abfac3bb419a10f57698204e \--hash=sha256:4dcab11967482d400853b396d042038e4c492a15a5d2f57259e2b5f89a32f755 \# via h2, hyper-hyperlink==19.0.0 \- --hash=sha256:4288e34705da077fada1111a24a0aa08bb1e76699c9ce49876af722441845654 \- --hash=sha256:ab4a308feb039b04f855a020a6eda3b18ca5a68e6d8f8c899cbe9e653721d04f \- # via -r requirements/common.inidna==2.8 \--hash=sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407 \--hash=sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c \- # via hyperlink, requests+ # via requestsijson==3.1.post0 \--hash=sha256:07cd88c9224392726128673fea7a90276746d3bf56d11635e3457769eda6295a \--hash=sha256:0ae656f3ca3bd833dc548583f13ba205eaee7c15d27496091549de4523931e00 \diff --git a/version.py b/version.pyindex bafce853fec..cb7ee659642 100644--- a/version.py+++ b/version.py@@ -44,4 +44,4 @@ API_FEATURE_LEVEL = 32# historical commits sharing the same major version, in which case a# minor version bump suffices.-PROVISION_VERSION = '102.0'+PROVISION_VERSION = '103.0'diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.pyindex af20f7e5e58..132d81c62c8 100644--- a/zerver/lib/markdown/__init__.py+++ b/zerver/lib/markdown/__init__.py@@ -26,6 +26,7 @@ from typing import (Union,)from typing.re import Match, Pattern+from urllib.parse import urlsplitfrom xml.etree import ElementTree as etreefrom xml.etree.ElementTree import Element, SubElement@@ -36,7 +37,6 @@ import markdownimport requestsfrom django.conf import settingsfrom django.db.models import Q-from hyperlink import parsefrom markdown.extensions import codehilite, nl2br, sane_lists, tablesfrom typing_extensions import TypedDict@@ -2077,9 +2077,12 @@ def topic_links(realm_filters_key: int, topic_name: str) -> List[str]:link_match = re.match(get_web_link_regex(), sub_string)if link_match:url = link_match.group('url')- url_object = parse(url)- if not url_object.scheme:- url = url_object.replace(scheme='https').to_text()+ result = urlsplit(url)+ if not result.scheme:+ if not result.netloc:+ i = (result.path + "/").index("/")+ result = result._replace(netloc=result.path[:i], path=result.path[i:])+ url = result._replace(scheme="https").geturl()matches.append(url)return matches