File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1818import zlib
1919from functools import lru_cache , wraps
2020from typing import Optional
21+ import importlib .metadata
2122
2223from django .conf import settings
2324from django .core .exceptions import ImproperlyConfigured
@@ -254,4 +255,14 @@ def _django_csp_update_decorator():
254255 else :
255256 # autosubmit of forms uses nonce per default
256257 # form-action https: to send data to IdPs
257- return csp_update (FORM_ACTION = ["https:" ])
258+ try :
259+ csp_version = importlib .metadata .version ("django-csp" )
260+ except importlib .metadata .PackageNotFoundError :
261+ csp_version = "0"
262+
263+ major_version = int (csp_version .split ("." )[0 ])
264+
265+ if major_version >= 4 :
266+ return csp_update ({"form-action" : ["https:" ]})
267+ else :
268+ return csp_update (FORM_ACTION = ["https:" ])
You can’t perform that action at this time.
0 commit comments