diff --git a/sanctions/src/main.py b/sanctions/src/main.py index 0f8023d..8108c74 100644 --- a/sanctions/src/main.py +++ b/sanctions/src/main.py @@ -4,6 +4,7 @@ Sprint 1: Name screening against OpenSanctions (yente) with LLM enhancement. """ +import html as html_lib import json import os @@ -70,6 +71,9 @@ async def search_ui(request: Request, q: str = "", threshold: float = 0.7): error = None raw_json = "" + def escape_text(value: object) -> str: + return html_lib.escape(str(value), quote=True) + if q: try: results = await _query_yente(q, threshold) @@ -106,17 +110,20 @@ def dataset_badge(ds: str) -> str: "peps": ("bg-orange-100 text-orange-800", "PEP"), } cls, label = colors.get(ds, ("bg-gray-100 text-gray-700", ds.upper())) - return f'{label}' + return ( + f'' + f"{escape_text(label)}" + ) def prop_row(key: str, vals: list) -> str: if not vals: return "" - joined = " · ".join(str(v) for v in vals[:5]) + joined = " · ".join(escape_text(v) for v in vals[:5]) if len(vals) > 5: joined += f" +{len(vals)-5} weitere" return f"""
ID: {m['id']}
+ID: {safe_id}
{raw_json}
+ {safe_raw_json}