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