diff --git a/tests/test_web_ui_handlers.py b/tests/test_web_ui_handlers.py index 5dc48a2..3d8b37e 100644 --- a/tests/test_web_ui_handlers.py +++ b/tests/test_web_ui_handlers.py @@ -116,13 +116,27 @@ def test_authenticated_render_path(web_ui, monkeypatch): def test_hostile_fields_are_escaped_not_reflected_raw(web_ui, monkeypatch): """Regression lock: hostile field values must reach the HTML only as escaped - entities -- no raw " not in body # never reflected raw assert "<script>alert(1)</script>" in body # escaped form present + + # attribute context: the id flows through json.dumps into + # onclick="window.location={esc(..., quote=True)}", so the JSON string's + # opening quote must render as " -- a raw " right after the = means + # quote-escaping regressed and the attribute is breakable + assert "window.location="" in body + assert 'window.location="' not in body + + # the payload's own quote characters appear only entity-escaped + assert """ in body + assert "'" in body + assert _HOSTILE not in body