diff --git a/webapp/main.py b/webapp/main.py index 70b1d6a..d9c14f9 100644 --- a/webapp/main.py +++ b/webapp/main.py @@ -216,12 +216,14 @@ def viewer( home: Optional[str] = Query(None), ): sections = fetch_sections(prefix) + # Escape < so inside text_html cannot break the page script tag + sections_json = json.dumps(sections, ensure_ascii=False, default=str).replace("<", "\\u003c") home_url = "/home-image" if (home or HOME_IMAGE or (BASE_DIR.parent / "Bairaci.png").exists()) else None return templates.TemplateResponse( request, "viewer.html", { - "sections_json": json.dumps(sections, ensure_ascii=False, default=str), + "sections_json": sections_json, "section_count": len(sections), "prefix": prefix or "", "home_url": home_url, diff --git a/webapp/templates/viewer.html b/webapp/templates/viewer.html index 55b8e88..d7d81aa 100644 --- a/webapp/templates/viewer.html +++ b/webapp/templates/viewer.html @@ -335,21 +335,44 @@
+