Skip to content

Commit 153696e

Browse files
authored
Merge pull request #226 from sevdog/improve-conditions
Use simple logical operator in middleware
2 parents b348924 + f11be06 commit 153696e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

csp/middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def process_response(self, request: HttpRequest, response: HttpResponseBase) ->
5757
policy = getattr(settings, "CONTENT_SECURITY_POLICY", None) or {}
5858
prefixes = policy.get("EXCLUDE_URL_PREFIXES", None) or ()
5959
is_not_excluded = not request.path_info.startswith(tuple(prefixes))
60-
if all((no_header, is_not_exempt, is_not_excluded)):
60+
if no_header and is_not_exempt and is_not_excluded:
6161
response[HEADER] = csp
6262

6363
csp_ro = self.build_policy_ro(request, response)
@@ -68,7 +68,7 @@ def process_response(self, request: HttpRequest, response: HttpResponseBase) ->
6868
policy = getattr(settings, "CONTENT_SECURITY_POLICY_REPORT_ONLY", None) or {}
6969
prefixes = policy.get("EXCLUDE_URL_PREFIXES", None) or ()
7070
is_not_excluded = not request.path_info.startswith(tuple(prefixes))
71-
if all((no_header, is_not_exempt, is_not_excluded)):
71+
if no_header and is_not_exempt and is_not_excluded:
7272
response[HEADER_REPORT_ONLY] = csp_ro
7373

7474
return response

0 commit comments

Comments
 (0)