Opened 11 minutes ago
#37537 new Bug
CSP build_policy should support lazy URLs
| Reported by: | Claude Paroz | Owned by: | |
|---|---|---|---|
| Component: | CSP | Version: | 6.1 |
| Severity: | Normal | Keywords: | |
| Cc: | Claude Paroz | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
When setting a lazy URL (reverse_lazy) in SECURE_CSP_REPORT_ONLY["report-uri"], the build_policy function crashes with the following traceback:
File "<venv>/lib/python3.13/site-packages/django/utils/csp.py", line 124, in build_policy
rendered_value = " ".join(values)
TypeError: sequence item 0: expected str instance, __proxy__ found
It should be rather straightforward to force resolution of lazy values before joining.
Note:
See TracTickets
for help on using tickets.