use util.is_web() more

pull/344/head
Ryan Barrett 2022-12-10 09:04:05 -08:00
rodzic 8751fea257
commit 47aec1c5ea
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
4 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -21,7 +21,7 @@ CACHE_TIME = datetime.timedelta(seconds=15)
def add_wm(url=None):
"""Proxies HTTP requests and adds Link header to our webmention endpoint."""
url = urllib.parse.unquote(url)
if not url.startswith('http://') and not url.startswith('https://'):
if not util.is_web(url):
error('URL must start with http:// or https://')
try:

Wyświetl plik

@ -36,7 +36,7 @@ def remote_follow():
if len(split) == 2:
addr_domain = split[1]
resource = f'acct:{addr}'
elif addr.startswith('http://') or addr.startswith('https://'):
elif util.is_web(addr):
addr_domain = util.domain_from_link(addr, minimize=False)
resource = addr
else:

Wyświetl plik

@ -43,7 +43,7 @@ def redir(to):
# if that happened to this URL, expand it back to two /s.
to = re.sub(r'^(https?:/)([^/])', r'\1/\2', to)
if not to.startswith('http://') and not to.startswith('https://'):
if not util.is_web(to):
error(f'Expected fully qualified URL; got {to}')
# check that we've seen this domain before so we're not an open redirect

Wyświetl plik

@ -186,7 +186,7 @@ class Webfinger(Actor):
domain = urllib.parse.urlparse(resource).netloc or resource
url = None
if resource.startswith('http://') or resource.startswith('https://'):
if util.is_web(resource):
url = resource
return super().template_vars(domain=domain, url=url)