mirror of https://github.com/zulip/zulip.git
markdown: Replace hyperlink requirement with urllib.parse.
The previous code only worked by accident and hyperlink 20.0.0 breaks it. >>> hyperlink.parse("example.com").replace(scheme="https") DecodedURL(url=URL.from_text('https:example.com')) Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
f39d4cf1f0
commit
dfab09b17d
|
@ -18,7 +18,6 @@ Jinja2
|
||||||
Markdown
|
Markdown
|
||||||
importlib-metadata;python_version<"3.8" # for Markdown
|
importlib-metadata;python_version<"3.8" # for Markdown
|
||||||
Pygments
|
Pygments
|
||||||
hyperlink
|
|
||||||
jsx-lexer
|
jsx-lexer
|
||||||
|
|
||||||
# Needed for manage.py
|
# Needed for manage.py
|
||||||
|
|
|
@ -368,7 +368,7 @@ hyperframe==3.2.0 \
|
||||||
hyperlink==19.0.0 \
|
hyperlink==19.0.0 \
|
||||||
--hash=sha256:4288e34705da077fada1111a24a0aa08bb1e76699c9ce49876af722441845654 \
|
--hash=sha256:4288e34705da077fada1111a24a0aa08bb1e76699c9ce49876af722441845654 \
|
||||||
--hash=sha256:ab4a308feb039b04f855a020a6eda3b18ca5a68e6d8f8c899cbe9e653721d04f \
|
--hash=sha256:ab4a308feb039b04f855a020a6eda3b18ca5a68e6d8f8c899cbe9e653721d04f \
|
||||||
# via -r requirements/common.in, twisted
|
# via twisted
|
||||||
idna==2.8 \
|
idna==2.8 \
|
||||||
--hash=sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407 \
|
--hash=sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407 \
|
||||||
--hash=sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c \
|
--hash=sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c \
|
||||||
|
|
|
@ -257,14 +257,10 @@ hyperframe==3.2.0 \
|
||||||
--hash=sha256:05f0e063e117c16fcdd13c12c93a4424a2c40668abfac3bb419a10f57698204e \
|
--hash=sha256:05f0e063e117c16fcdd13c12c93a4424a2c40668abfac3bb419a10f57698204e \
|
||||||
--hash=sha256:4dcab11967482d400853b396d042038e4c492a15a5d2f57259e2b5f89a32f755 \
|
--hash=sha256:4dcab11967482d400853b396d042038e4c492a15a5d2f57259e2b5f89a32f755 \
|
||||||
# via h2, hyper
|
# via h2, hyper
|
||||||
hyperlink==19.0.0 \
|
|
||||||
--hash=sha256:4288e34705da077fada1111a24a0aa08bb1e76699c9ce49876af722441845654 \
|
|
||||||
--hash=sha256:ab4a308feb039b04f855a020a6eda3b18ca5a68e6d8f8c899cbe9e653721d04f \
|
|
||||||
# via -r requirements/common.in
|
|
||||||
idna==2.8 \
|
idna==2.8 \
|
||||||
--hash=sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407 \
|
--hash=sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407 \
|
||||||
--hash=sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c \
|
--hash=sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c \
|
||||||
# via hyperlink, requests
|
# via requests
|
||||||
ijson==3.1.post0 \
|
ijson==3.1.post0 \
|
||||||
--hash=sha256:07cd88c9224392726128673fea7a90276746d3bf56d11635e3457769eda6295a \
|
--hash=sha256:07cd88c9224392726128673fea7a90276746d3bf56d11635e3457769eda6295a \
|
||||||
--hash=sha256:0ae656f3ca3bd833dc548583f13ba205eaee7c15d27496091549de4523931e00 \
|
--hash=sha256:0ae656f3ca3bd833dc548583f13ba205eaee7c15d27496091549de4523931e00 \
|
||||||
|
|
|
@ -44,4 +44,4 @@ API_FEATURE_LEVEL = 32
|
||||||
# historical commits sharing the same major version, in which case a
|
# historical commits sharing the same major version, in which case a
|
||||||
# minor version bump suffices.
|
# minor version bump suffices.
|
||||||
|
|
||||||
PROVISION_VERSION = '102.0'
|
PROVISION_VERSION = '103.0'
|
||||||
|
|
|
@ -26,6 +26,7 @@ from typing import (
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
from typing.re import Match, Pattern
|
from typing.re import Match, Pattern
|
||||||
|
from urllib.parse import urlsplit
|
||||||
from xml.etree import ElementTree as etree
|
from xml.etree import ElementTree as etree
|
||||||
from xml.etree.ElementTree import Element, SubElement
|
from xml.etree.ElementTree import Element, SubElement
|
||||||
|
|
||||||
|
@ -36,7 +37,6 @@ import markdown
|
||||||
import requests
|
import requests
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from hyperlink import parse
|
|
||||||
from markdown.extensions import codehilite, nl2br, sane_lists, tables
|
from markdown.extensions import codehilite, nl2br, sane_lists, tables
|
||||||
from typing_extensions import TypedDict
|
from 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)
|
link_match = re.match(get_web_link_regex(), sub_string)
|
||||||
if link_match:
|
if link_match:
|
||||||
url = link_match.group('url')
|
url = link_match.group('url')
|
||||||
url_object = parse(url)
|
result = urlsplit(url)
|
||||||
if not url_object.scheme:
|
if not result.scheme:
|
||||||
url = url_object.replace(scheme='https').to_text()
|
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)
|
matches.append(url)
|
||||||
|
|
||||||
return matches
|
return matches
|
||||||
|
|
Loading…
Reference in New Issue