Fix viewer: safe JSON embed so search cards render again.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-26 10:51:37 +03:00
parent a31c8d678c
commit 1c7874a31e
2 changed files with 45 additions and 24 deletions

View File

@@ -216,12 +216,14 @@ def viewer(
home: Optional[str] = Query(None),
):
sections = fetch_sections(prefix)
# Escape < so </script> 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,