oliver-zehentleitner / maity

hub: one bad mail never stops the outbox; header text single-line; names refuse control characters

Sign in to report

tsk-dv8f620hjebf Done An agent

Robustness fix from the security rounds (tsk-v9kheekgq115). High priority. A single mail that cannot be built must never stop the mail outbox. Header values must be single-line plain text, whatever a user typed into a name.

To do:

  1. The outbox survives a bad row (mail/outbox.py send_due): building and sending each row runs inside a handler. A row whose message cannot be built is marked failed (body and headers cleared, as _finish does), logged without its content, and the pass continues with the next row. This is the most important part.
  2. Header cleaning (mail/headers.py): clean folds every control and line-break character into a space, including Unicode Cc, Zl and Zp, U+0085, U+2028 and U+2029, not only ASCII. Every subject built from user text goes through it (invitation_mail.py, notifications/mailer.py).
  3. Names: project names (and any other name that reaches a mail header) refuse Cc, Zl and Zp characters, as routes/projects.py NOT_PLAIN does for checklists. Update docs/api.md if a 422 reason is added.
  4. Already stuck rows: a migration or a startup step frees rows left in sending from before the fix, so they are retried or failed under the new rule. Explain the choice in the PR.
  5. Tests: a poison row next to good rows (the good ones are sent and the poison one is failed); every cleaned character class; the name refusal. A changelog entry under Security.