From 63ee0e0c54ae86820e039433440918de36918a60 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 10 Jan 2023 14:09:35 +0000 Subject: [PATCH] Protocol handler can have path after domain --- webfinger.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/webfinger.py b/webfinger.py index 257147862..a007d5cd3 100644 --- a/webfinger.py +++ b/webfinger.py @@ -277,13 +277,16 @@ def wellknown_protocol_handler(path: str, base_dir: str, handle = handle[1:] if '@' in handle: nickname = handle.split('@')[0] - domain = handle.split('@')[1] + domain_and_path = handle.split('@')[1] else: nickname = handle - domain = domain_full + domain_and_path = domain_full # not an open redirect - if domain == domain_full: - return http_prefix + '://' + domain_full + '/users/' + nickname + if domain_and_path.startswith(domain_full): + domain_length = len(domain_full) + path_str = domain_and_path[domain_length:] + return http_prefix + '://' + domain_full + \ + '/users/' + nickname + path_str return None