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 Jul 8, 2024
1 parent b348924 commit f11be06
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 @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit f11be06

Please sign in to comment.