Fix session-count script rendered as visible text

_GET_SESSION_COUNT_SCRIPT was a mark_safe string used as a child of the
view_game content tree. Under the "only Safe nodes render unescaped" rule, a
mark_safe *string* child is escaped — so the <script> showed as literal text
on the page. Make it a Safe node (and drop the now-unused mark_safe import).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 22:17:10 +02:00
parent 138136e285
commit 3fb9aa9f84
+2 -2
View File
@@ -8,7 +8,7 @@ from django.middleware.csrf import get_token
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
from django.template.defaultfilters import date as date_filter from django.template.defaultfilters import date as date_filter
from django.urls import reverse from django.urls import reverse
from django.utils.safestring import SafeText, mark_safe from django.utils.safestring import SafeText
from common.components import ( from common.components import (
Fragment, Fragment,
@@ -791,7 +791,7 @@ def _history_section(game: Game) -> SafeText:
) )
_GET_SESSION_COUNT_SCRIPT = mark_safe( _GET_SESSION_COUNT_SCRIPT = Safe(
"<script>\n" "<script>\n"
" function getSessionCount() {\n" " function getSessionCount() {\n"
" return document.getElementById('session-count')" " return document.getElementById('session-count')"