Fjern inline onsubmit med innholdstekst (XSS i JS-attributt)
Jinja escaper for HTML, men nettleseren dekoder attributtverdien før JS-parseren ser den, så en tittel med ' kunne bryte ut av strengen. Bekreftelser går nå via data-confirm og én delt handler i base.html. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcEy43fNYpwg6K6oTKakWR
This commit is contained in:
parent
227faff373
commit
4794db76b0
4 changed files with 22 additions and 5 deletions
|
|
@ -146,3 +146,14 @@ def test_subpath_mount(tmp_path):
|
|||
assert 'href="theme/style.css"' in html
|
||||
assert re.search(r'href="admin/"', html)
|
||||
assert client.get("/blog/theme/style.css").status_code == 200
|
||||
|
||||
|
||||
def test_no_inline_js_with_content(client, cfg):
|
||||
"""Titler med anførselstegn skal ikke havne i en JS-kontekst (XSS)."""
|
||||
post_id = _create_post(client)
|
||||
token = csrf(client)
|
||||
title = "Ola's \"test\" <b>"
|
||||
r = client.post(f"/admin/edit/{post_id}", data={"csrf": token, "title": title, "body": "x", "action": "save"})
|
||||
html = client.get(r.headers["Location"]).text
|
||||
assert "onsubmit" not in html and "onclick" not in html
|
||||
assert "Ola's" in html
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue