From f11be062e7b300f690a6ef2db811266fbf60e8b2 Mon Sep 17 00:00:00 2001 From: Davide Date: Fri, 21 Jun 2024 08:59:43 +0200 Subject: [PATCH] Use simple logical operator in middleware --- csp/middleware.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/csp/middleware.py b/csp/middleware.py index ff58c61..754c80d 100644 --- a/csp/middleware.py +++ b/csp/middleware.py @@ -57,7 +57,7 @@ def process_response(self, request: HttpRequest, response: HttpResponseBase) -> policy = getattr(settings, "CONTENT_SECURITY_POLICY", None) or {} prefixes = policy.get("EXCLUDE_URL_PREFIXES", None) or () is_not_excluded = not request.path_info.startswith(tuple(prefixes)) - if all((no_header, is_not_exempt, is_not_excluded)): + if no_header and is_not_exempt and is_not_excluded: response[HEADER] = csp csp_ro = self.build_policy_ro(request, response) @@ -68,7 +68,7 @@ def process_response(self, request: HttpRequest, response: HttpResponseBase) -> policy = getattr(settings, "CONTENT_SECURITY_POLICY_REPORT_ONLY", None) or {} prefixes = policy.get("EXCLUDE_URL_PREFIXES", None) or () is_not_excluded = not request.path_info.startswith(tuple(prefixes)) - if all((no_header, is_not_exempt, is_not_excluded)): + if no_header and is_not_exempt and is_not_excluded: response[HEADER_REPORT_ONLY] = csp_ro return response