summaryrefslogtreecommitdiff
path: root/django/utils/csp.py
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2025-07-22 20:41:41 -0700
committernessita <124304+nessita@users.noreply.github.com>2025-07-23 20:17:55 -0300
commit69a93a88edb56ba47f624dac7a21aacc47ea474f (patch)
treef57507a4435d032493cae40e06ecb254790b67b2 /django/utils/csp.py
parent55b0cc21310b76ce4018dd793ba50556eaf0af06 (diff)
Refs #36500 -- Rewrapped long docstrings and block comments via a script.
Rewrapped long docstrings and block comments to 79 characters + newline using script from https://github.com/medmunds/autofix-w505.
Diffstat (limited to 'django/utils/csp.py')
-rw-r--r--django/utils/csp.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/django/utils/csp.py b/django/utils/csp.py
index b989a47c23..d57fc98995 100644
--- a/django/utils/csp.py
+++ b/django/utils/csp.py
@@ -9,7 +9,8 @@ class CSP(StrEnum):
Content Security Policy constants for directive values and special tokens.
These constants represent:
- 1. Standard quoted string values from the CSP spec (e.g., 'self', 'unsafe-inline')
+ 1. Standard quoted string values from the CSP spec (e.g., 'self',
+ 'unsafe-inline')
2. Special placeholder tokens (NONCE) that get replaced by the middleware
Using this enum instead of raw strings provides better type checking,
@@ -43,13 +44,15 @@ class CSP(StrEnum):
WASM_UNSAFE_EVAL = "'wasm-unsafe-eval'"
# Special placeholder that gets replaced by the middleware.
- # The value itself is arbitrary and should not be mistaken for a real nonce.
+ # The value itself is arbitrary and should not be mistaken for a real
+ # nonce.
NONCE = "<CSP_NONCE_SENTINEL>"
class LazyNonce(SimpleLazyObject):
"""
- Lazily generates a cryptographically secure nonce string, for use in CSP headers.
+ Lazily generates a cryptographically secure nonce string, for use in CSP
+ headers.
The nonce is only generated when first accessed (e.g., via string
interpolation or inside a template).
@@ -62,7 +65,8 @@ class LazyNonce(SimpleLazyObject):
<script{% if csp_nonce %} nonce="{{ csp_nonce }}"...{% endif %}>
- The `{% if %}` block will only render if the nonce has been evaluated elsewhere.
+ The `{% if %}` block will only render if the nonce has been evaluated
+ elsewhere.
"""