mirror of https://gitlab.com/bashrc2/epicyon
Allow for protocol handler commands
parent
fdafb02729
commit
0626ba32d5
|
@ -1732,15 +1732,15 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# protocol handler. See https://fedi-to.github.io/protocol-handler.html
|
# protocol handler. See https://fedi-to.github.io/protocol-handler.html
|
||||||
if self.path.startswith('/.well-known/protocol-handler'):
|
if self.path.startswith('/.well-known/protocol-handler'):
|
||||||
if calling_domain.endswith('.onion'):
|
if calling_domain.endswith('.onion'):
|
||||||
protocol_url = \
|
protocol_url, _ = \
|
||||||
wellknown_protocol_handler(self.path, 'http',
|
wellknown_protocol_handler(self.path, 'http',
|
||||||
self.server.onion_domain)
|
self.server.onion_domain)
|
||||||
elif calling_domain.endswith('.i2p'):
|
elif calling_domain.endswith('.i2p'):
|
||||||
protocol_url = \
|
protocol_url, _ = \
|
||||||
wellknown_protocol_handler(self.path,
|
wellknown_protocol_handler(self.path,
|
||||||
'http', self.server.i2p_domain)
|
'http', self.server.i2p_domain)
|
||||||
else:
|
else:
|
||||||
protocol_url = \
|
protocol_url, _ = \
|
||||||
wellknown_protocol_handler(self.path,
|
wellknown_protocol_handler(self.path,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
self.server.domain_full)
|
self.server.domain_full)
|
||||||
|
|
18
webfinger.py
18
webfinger.py
|
@ -252,12 +252,12 @@ def webfinger_meta(http_prefix: str, domain_full: str) -> str:
|
||||||
return meta_str
|
return meta_str
|
||||||
|
|
||||||
|
|
||||||
def wellknown_protocol_handler(path: str,
|
def wellknown_protocol_handler(path: str, http_prefix: str,
|
||||||
http_prefix: str, domain_full: str) -> {}:
|
domain_full: str) -> ({}, str):
|
||||||
"""See https://fedi-to.github.io/protocol-handler.html
|
"""See https://fedi-to.github.io/protocol-handler.html
|
||||||
"""
|
"""
|
||||||
if not path.startswith('/.well-known/protocol-handler?'):
|
if not path.startswith('/.well-known/protocol-handler?'):
|
||||||
return None
|
return None, None
|
||||||
|
|
||||||
if 'target=' in path:
|
if 'target=' in path:
|
||||||
path = urllib.parse.unquote(path)
|
path = urllib.parse.unquote(path)
|
||||||
|
@ -265,11 +265,11 @@ def wellknown_protocol_handler(path: str,
|
||||||
if ';' in target:
|
if ';' in target:
|
||||||
target = target.split(';')[0]
|
target = target.split(';')[0]
|
||||||
if not target:
|
if not target:
|
||||||
return None
|
return None, None
|
||||||
if not target.startswith('web+epicyon:') and \
|
if not target.startswith('web+epicyon:') and \
|
||||||
not target.startswith('web+mastodon:') and \
|
not target.startswith('web+mastodon:') and \
|
||||||
not target.startswith('web+ap:'):
|
not target.startswith('web+ap:'):
|
||||||
return None
|
return None, None
|
||||||
handle = target.split(':', 1)[1].strip()
|
handle = target.split(':', 1)[1].strip()
|
||||||
if handle.startswith('//'):
|
if handle.startswith('//'):
|
||||||
handle = handle[2:]
|
handle = handle[2:]
|
||||||
|
@ -283,11 +283,15 @@ def wellknown_protocol_handler(path: str,
|
||||||
domain_and_path = domain_full
|
domain_and_path = domain_full
|
||||||
# not an open redirect
|
# not an open redirect
|
||||||
if domain_and_path.startswith(domain_full):
|
if domain_and_path.startswith(domain_full):
|
||||||
|
command = ''
|
||||||
|
if '/' in nickname:
|
||||||
|
command = nickname.split('/')[0]
|
||||||
|
nickname = nickname.split('/')[1]
|
||||||
domain_length = len(domain_full)
|
domain_length = len(domain_full)
|
||||||
path_str = domain_and_path[domain_length:]
|
path_str = domain_and_path[domain_length:]
|
||||||
return http_prefix + '://' + domain_full + \
|
return http_prefix + '://' + domain_full + \
|
||||||
'/users/' + nickname + path_str
|
'/users/' + nickname + path_str, command
|
||||||
return None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
def webfinger_lookup(path: str, base_dir: str,
|
def webfinger_lookup(path: str, base_dir: str,
|
||||||
|
|
Loading…
Reference in New Issue