mirror of https://gitlab.com/bashrc2/epicyon
Redirect parameter
parent
375550c331
commit
bbbe6b21ea
10
daemon.py
10
daemon.py
|
@ -1117,7 +1117,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return False
|
||||
|
||||
def _redirect_headers(self, redirect: str, cookie: str,
|
||||
calling_domain: str) -> None:
|
||||
calling_domain: str,
|
||||
code: int = 303) -> None:
|
||||
if '://' not in redirect:
|
||||
if calling_domain.endswith('.onion') and self.server.onion_domain:
|
||||
redirect = 'http://' + self.server.onion_domain + redirect
|
||||
|
@ -1130,7 +1131,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
print('WARN: redirect was not an absolute url, changed to ' +
|
||||
redirect)
|
||||
|
||||
self.send_response(303)
|
||||
self.send_response(code)
|
||||
|
||||
if code != 303:
|
||||
print('Redirect headers: ' + str(code))
|
||||
|
||||
if cookie:
|
||||
cookie_str = cookie.replace('SET:', '').strip()
|
||||
|
@ -1743,7 +1747,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.domain_full)
|
||||
if protocol_url:
|
||||
self._redirect_headers(protocol_url, cookie,
|
||||
calling_domain)
|
||||
calling_domain, 308)
|
||||
else:
|
||||
self._404()
|
||||
return True
|
||||
|
|
|
@ -255,7 +255,6 @@ def webfinger_meta(http_prefix: str, domain_full: str) -> str:
|
|||
def wellknown_protocol_handler(path: str, base_dir: str,
|
||||
http_prefix: str, domain_full: str) -> {}:
|
||||
"""See https://fedi-to.github.io/protocol-handler.html
|
||||
Only return the path, not the full url
|
||||
"""
|
||||
if not path.startswith('/.well-known/protocol-handler?'):
|
||||
return None
|
||||
|
@ -282,7 +281,7 @@ def wellknown_protocol_handler(path: str, base_dir: str,
|
|||
domain = domain_full
|
||||
# not an open redirect
|
||||
if domain == domain_full:
|
||||
return '/users/' + nickname
|
||||
return http_prefix + '://' + domain_full + '/users/' + nickname
|
||||
return None
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue