fix: html-escape recipe/ingredient names in email templates (#P5-a, #P5-b)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-08 21:37:19 -07:00
co-authored by Claude Sonnet 4.6
parent 9a484d39c3
commit 3b28ad0e1c
2 changed files with 35 additions and 10 deletions
+23
View File
@@ -316,6 +316,29 @@ def test_step_email_stale_banner(db, weekly_run_generated, meal_plan, pending_it
assert "prices" in sent[0]["html"].lower() or "stale" in sent[0]["html"].lower()
def test_step_email_escapes_recipe_name(
db, weekly_run_generated, meal_plan, pending_item, member, monkeypatch
):
pending_item.recipe.name = "<script>alert('xss')</script>"
db.flush()
sent = []
class FakeBackend:
def send(self, **kwargs):
sent.append(kwargs)
monkeypatch.setattr(
"app.services.orchestrator.steps.get_email_backend",
lambda: FakeBackend(),
)
from app.services.orchestrator.steps import step_email
step_email(weekly_run_generated, db)
assert len(sent) == 1
assert "<script>" not in sent[0]["html"]
assert "&lt;script&gt;" in sent[0]["html"]
# ── step_reminder ──────────────────────────────────────────────────────────