fix: do not autoescape static tag

When using django-storage S3, this will escape the final static URL,
containing query string (so & will become &).
This commit is contained in:
Yohan Boniface 2024-12-17 13:07:46 +01:00
parent 05c27aed98
commit 6db3032bdb
6 changed files with 15 additions and 0 deletions

View file

@ -18,6 +18,7 @@
<meta name="viewport" <meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
{# See https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs #} {# See https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs #}
{% autoescape off %}
<link rel="icon" <link rel="icon"
href="{% static 'umap/favicons/favicon.ico' %}" href="{% static 'umap/favicons/favicon.ico' %}"
sizes="32x32"> sizes="32x32">
@ -28,6 +29,7 @@
href="{% static 'umap/favicons/apple-touch-icon.png' %}"> href="{% static 'umap/favicons/apple-touch-icon.png' %}">
<!-- 180×180 --> <!-- 180×180 -->
<link rel="manifest" href="/manifest.webmanifest"> <link rel="manifest" href="/manifest.webmanifest">
{% endautoescape %}
</head> </head>
<body class="{% block body_class %}{% endblock body_class %}"> <body class="{% block body_class %}{% endblock body_class %}">
{% block header %} {% block header %}

View file

@ -1,8 +1,10 @@
{% load i18n static %} {% load i18n static %}
{% autoescape off %}
<style type="text/css"> <style type="text/css">
@import "{% static 'umap/js/components/alerts/alert.css' %}"; @import "{% static 'umap/js/components/alerts/alert.css' %}";
</style> </style>
{% endautoescape %}
<template id="umap-alert-template"> <template id="umap-alert-template">
<div role="dialog" class="dark window umap-alert"> <div role="dialog" class="dark window umap-alert">
<div> <div>
@ -97,6 +99,7 @@
</div> </div>
</template> </template>
<umap-alert-conflict></umap-alert-conflict> <umap-alert-conflict></umap-alert-conflict>
{% autoescape off %}
<script type="module"> <script type="module">
import { register } from '{% static 'umap/js/components/base.js' %}' import { register } from '{% static 'umap/js/components/base.js' %}'
import { import {
@ -108,3 +111,4 @@
register(uMapAlertCreation, 'umap-alert-creation') register(uMapAlertCreation, 'umap-alert-creation')
register(uMapAlertConflict, 'umap-alert-conflict') register(uMapAlertConflict, 'umap-alert-conflict')
</script> </script>
{% endautoescape %}

View file

@ -1,5 +1,7 @@
{% load static %} {% load static %}
{% autoescape off %}
<link rel="stylesheet" <link rel="stylesheet"
href="{% static 'umap/vendors/leaflet/leaflet.css' %}" /> href="{% static 'umap/vendors/leaflet/leaflet.css' %}" />
<link rel="stylesheet" <link rel="stylesheet"
@ -39,3 +41,4 @@
<link rel="stylesheet" href="{% static 'umap/css/tableeditor.css' %}" /> <link rel="stylesheet" href="{% static 'umap/css/tableeditor.css' %}" />
<link rel="stylesheet" href="{% static 'umap/css/bar.css' %}" /> <link rel="stylesheet" href="{% static 'umap/css/bar.css' %}" />
<link rel="stylesheet" href="{% static 'umap/theme.css' %}" /> <link rel="stylesheet" href="{% static 'umap/theme.css' %}" />
{% endautoescape %}

View file

@ -1,5 +1,6 @@
{% load static %} {% load static %}
{% autoescape off %}
<script type="module" <script type="module"
src="{% static 'umap/vendors/leaflet/leaflet-src.esm.js' %}" src="{% static 'umap/vendors/leaflet/leaflet-src.esm.js' %}"
defer></script> defer></script>
@ -42,3 +43,4 @@
<script src="{% static 'umap/js/umap.forms.js' %}" defer></script> <script src="{% static 'umap/js/umap.forms.js' %}" defer></script>
<script src="{% static 'umap/js/umap.controls.js' %}" defer></script> <script src="{% static 'umap/js/umap.controls.js' %}" defer></script>
<script type="module" src="{% static 'umap/js/components/fragment.js' %}" defer></script> <script type="module" src="{% static 'umap/js/components/fragment.js' %}" defer></script>
{% endautoescape %}

View file

@ -5,7 +5,9 @@
</div> </div>
<!-- djlint:off --> <!-- djlint:off -->
<script defer type="module"> <script defer type="module">
{% autoescape off %}
import Umap from '{% static "umap/js/modules/umap.js" %}' import Umap from '{% static "umap/js/modules/umap.js" %}'
{% endautoescape %}
U.MAP = new Umap("map", {{ map_settings|notag|safe }}) U.MAP = new Umap("map", {{ map_settings|notag|safe }})
</script> </script>
<!-- djlint:on --> <!-- djlint:on -->

View file

@ -46,7 +46,9 @@
{% block bottom_js %} {% block bottom_js %}
{{ block.super }} {{ block.super }}
<script type="module"> <script type="module">
{% autoescape off %}
import Umap from '{% static "umap/js/modules/umap.js" %}' import Umap from '{% static "umap/js/modules/umap.js" %}'
{% endautoescape %}
const CACHE = {} const CACHE = {}
for (const mapOpener of document.querySelectorAll("button.map-opener")) { for (const mapOpener of document.querySelectorAll("button.map-opener")) {
mapOpener.addEventListener('click', (event) => { mapOpener.addEventListener('click', (event) => {