From 1c7874a31e7c4635c648893e1308d061d2d3f537 Mon Sep 17 00:00:00 2001 From: sabo Date: Wed, 26 Aug 2026 10:51:37 +0300 Subject: [PATCH] Fix viewer: safe JSON embed so search cards render again. Co-authored-by: Cursor --- webapp/main.py | 4 ++- webapp/templates/viewer.html | 65 +++++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 24 deletions(-) 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 @@
+