From 37a8d8a135e223057dc3b2ca2c3f7425cc880c7e Mon Sep 17 00:00:00 2001 From: Jacques van Zuydam Date: Wed, 7 Jan 2026 12:18:32 +0200 Subject: [PATCH] fix(Webserver): On ASGI response, a header containing an location with a ":" would be split incorrectly, thus the redirect would fail. Splitting only first ":" character now and skipping any malformed header. --- tina4_python/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tina4_python/__init__.py b/tina4_python/__init__.py index 7ad2552..052ea40 100644 --- a/tina4_python/__init__.py +++ b/tina4_python/__init__.py @@ -413,8 +413,19 @@ async def app(scope, receive, send): if message["type"] != "websocket": response_headers = [] for header in tina4_headers: - header = header.split(":") - response_headers.append([header[0].strip().encode(), header[1].strip().encode()]) + # ensure header is a str + if isinstance(header, bytes): + header = header.decode() + else: + header = str(header) + + # split only on the first ':' to preserve ':' in values (e.g. URLs with ports) + name, sep, value = header.partition(":") + if not sep: + # malformed header, skip it + continue + + response_headers.append([name.strip().encode(), value.lstrip().encode()]) await send({ 'type': 'http.response.start',