From f7ca8c15dd79d7d09f637c0999b305f51feb5e54 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 04 2019 15:28:39 +0000 Subject: Make the CSP header be bytes not unicode Header names must be byte string not unicode string, so we need to make sure our CSP header complies with that. Otherwise we run into: Apache returning a 500 error: TypeError: expected byte string object for header name, value of type unicode found Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/flask_app.py b/pagure/flask_app.py index 79a912c..6f16786 100644 --- a/pagure/flask_app.py +++ b/pagure/flask_app.py @@ -502,7 +502,7 @@ def after_request(response): csp_headers = csp_headers.format(nonce=flask.g.nonce) except (KeyError, IndexError): pass - response.headers.set("Content-Security-Policy", csp_headers) + response.headers.set(str("Content-Security-Policy"), csp_headers) return response