fix(web): Ensure that header values are strings (#28760)

This commit is contained in:
Corentin Forler 2024-12-12 15:02:12 +01:00 committed by GitHub
parent 0c8e49b72b
commit 50020cffda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -546,14 +546,14 @@ def build_response(path, data, http_status_code, headers: dict | None = None):
response = Response()
response.data = set_content_type(response, data, path)
response.status_code = http_status_code
response.headers["X-Page-Name"] = cstr(path.encode("ascii", errors="xmlcharrefreplace"))
response.headers["X-Page-Name"] = cstr(cstr(path).encode("ascii", errors="xmlcharrefreplace"))
response.headers["X-From-Cache"] = frappe.local.response.from_cache or False
add_preload_for_bundled_assets(response)
if headers:
for key, val in headers.items():
response.headers[key] = cstr(val.encode("ascii", errors="xmlcharrefreplace"))
response.headers[key] = cstr(cstr(val).encode("ascii", errors="xmlcharrefreplace"))
return response