Skip to content

Commit f395c85

Browse files
committed
Use simple logical operator in middleware
1 parent 45cb61a commit f395c85

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
@@ -47,7 +47,7 @@ def process_response(self, request, response):
4747
no_header = HEADER not in response
4848
prefixes = getattr(settings, "CONTENT_SECURITY_POLICY", {}).get("EXCLUDE_URL_PREFIXES", ())
4949
is_not_excluded = not request.path_info.startswith(prefixes)
50-
if all((no_header, is_not_exempt, is_not_excluded)):
50+
if no_header and is_not_exempt and is_not_excluded:
5151
response[HEADER] = csp
5252

5353
csp_ro = self.build_policy_ro(request, response)
@@ -57,7 +57,7 @@ def process_response(self, request, response):
5757
no_header = HEADER_REPORT_ONLY not in response
5858
prefixes = getattr(settings, "CONTENT_SECURITY_POLICY_REPORT_ONLY", {}).get("EXCLUDE_URL_PREFIXES", ())
5959
is_not_excluded = not request.path_info.startswith(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_REPORT_ONLY] = csp_ro
6262

6363
return response

0 commit comments

Comments
 (0)