diff --git a/csp/contrib/formatted_policy.py b/csp/contrib/formatted_policy.py index 60fbb73..6592aef 100644 --- a/csp/contrib/formatted_policy.py +++ b/csp/contrib/formatted_policy.py @@ -24,7 +24,10 @@ def build_policy(self, request, response): request, response, ): format_kwargs = { - field_name for _, field_name, _, _ in formatter.parse(csp) + # field_name ::= arg_name ("." attribute_name | "[" element_index "]")* + field_name[: next((i for i, c in enumerate(field_name) if c in ".["), None)] + for _, field_name, _, _ in formatter.parse(csp) + if field_name is not None } if format_kwargs: for name in format_kwargs: