Skip to content

Commit e33e544

Browse files
committed
Use a nonce for languageCode script
1 parent 606defa commit e33e544

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

apps/core/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
{% include "components/search_modal.html" %}
9696

9797
{# Global javascript #}
98-
<script>var languageCode = '{{ self.locale.language_code }}';</script>
98+
<script nonce="{{ request.csp_nonce }}">var languageCode = '{{ self.locale.language_code }}';</script>
9999
<script src="{% url 'javascript-catalog' %}"></script>
100100
<script src="{% manifest 'main.js' %}"></script>
101101

apps/guide/settings/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@
214214

215215
CSP_REPORT_ONLY = env.get("CSP_REPORT_ONLY", "false").lower() == "true"
216216

217+
CSP_INCLUDE_NONCE_IN = ["script-src", "style-src"]
218+
217219
# The “special” source values of
218220
# 'self', 'unsafe-inline', 'unsafe-eval', and 'none' must be quoted!
219221
# e.g.: CSP_DEFAULT_SRC = "'self'" Without quotes they will not work as intended.

0 commit comments

Comments
 (0)