From addf767d192dcee5e6d2d47b78cd896d12f217c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 7 Nov 2021 19:37:12 +0200 Subject: [PATCH] Handle redirects that include a fragment --- untls_proxy.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/untls_proxy.py b/untls_proxy.py index 44b2adb..9490f7b 100755 --- a/untls_proxy.py +++ b/untls_proxy.py @@ -140,6 +140,8 @@ class HtmlProcessor: attribute = self.attribute.lower() # TODO: handle more attributes if tag == b'a' and attribute == b'href' or tag == b'img' and attribute == b'src': + # TODO: entities + # TODO: keep leading whitespace already in there if self.value.strip().lower().startswith(b'https://'): # Space is to keep the response size constant return b' http://' + self.value.strip()[len(b'https://'):] @@ -441,7 +443,7 @@ def proxy(sock, host): if destination_url.startswith(b'https://'): destination_url = b'http://' + destination_url[len(b'https://'):] - if destination_url != url: + if destination_url.split(b'#')[0] != url: rewritten_response.extend(b'Location: ') rewritten_response.extend(destination_url) rewritten_response.extend(b'\r\n')