Skip to content

Commit e0c9c7a

Browse files
author
Maximilian Friedersdorff
committed
Don't test nonce for truthiness before inclusion
As of version 4.0 of django-csp, the behavior of the object that wraps the nonce in the request and/or context has changed. Testing for truthiness now returns `False` instead of `True`. The truthiness check is unnecessary anyway, skipping it is compatible with all versions of django-csp. Probably more performant too, template rendering wise. Not that it matters.
1 parent 18de9dd commit e0c9c7a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

leaflet/templates/leaflet/_leaflet_map.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{% load static %}
33
{% if creatediv %}<div id="{{ name }}" class="leaflet-container-default"></div>{% endif %}
44

5-
<script {% if csp_nonce %}nonce="{{ csp_nonce }}"{% endif %}>
5+
<script nonce="{{ csp_nonce }}">
66
(function () {
77

88
function loadmap() {

leaflet/templates/leaflet/widget.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
{{ FORCE_IMAGE_PATH|json_script:"force-img-path" }}
55
{{ reset_view_icon|json_script:"Control-ResetView-ICON" }}
66

7-
<style {% if csp_nonce %}nonce="{{ csp_nonce }}"{% endif %}>
7+
<style nonce="{{ csp_nonce }}">
88
{% block map_css %}
99
{% if map_width and map_height %}#{{ id_map }} { width: {{ map_width|unlocalize }}; height: {{ map_height|unlocalize }}; }{% endif %}
1010
{% if not display_raw %}#{{ id_css }} { display: none; }{% endif %}
1111
{% endblock map_css %}
1212
</style>
1313

14-
<script {% if csp_nonce %}nonce="{{ csp_nonce }}"{% endif %}>
14+
<script nonce="{{ csp_nonce }}">
1515
{% block vars %}var {{ module }} = {};
1616
{{ module }}.fieldid = '{{ id_css }}';
1717
{{ module }}.modifiable = {{ modifiable|yesno:"true,false" }};

0 commit comments

Comments
 (0)