import asyncio import tempfile import unittest from pathlib import Path import apps.base.pages as pages from core.settings import settings class IndexTemplateEscapingTests(unittest.TestCase): """Regression: site config must be html.escape-d before template injection (stored XSS prevention). Uses a temp file as a stand-in for themes/*/index.html so the test also runs in a bare checkout without built frontends. """ def setUp(self): self._original_user_config = dict(settings.user_config) self._original_resolve_theme_file = pages.resolve_theme_file pages._render_index_html.cache_clear() tmp = tempfile.NamedTemporaryFile( "w", suffix=".html", delete=False, encoding="utf-8" ) tmp.write( "