kopia lustrzana https://github.com/snarfed/bridgy-fed
use util.is_web() more
rodzic
8751fea257
commit
47aec1c5ea
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Ładowanie…
Reference in New Issue