Skip to content

Commit

Permalink
Use simple logical operator in middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
sevdog committed Jun 21, 2024
1 parent 45cb61a commit f395c85
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions csp/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def process_response(self, request, response):
no_header = HEADER not in response
prefixes = getattr(settings, "CONTENT_SECURITY_POLICY", {}).get("EXCLUDE_URL_PREFIXES", ())
is_not_excluded = not request.path_info.startswith(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)
Expand All @@ -57,7 +57,7 @@ def process_response(self, request, response):
no_header = HEADER_REPORT_ONLY not in response
prefixes = getattr(settings, "CONTENT_SECURITY_POLICY_REPORT_ONLY", {}).get("EXCLUDE_URL_PREFIXES", ())
is_not_excluded = not request.path_info.startswith(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
Expand Down

0 comments on commit f395c85

Please sign in to comment.