hub: one bad mail never stops the outbox; header text single-line; names refuse control characters
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:
- The outbox survives a bad row (
mail/outbox.pysend_due): building and sending each row runs inside a handler. A row whose message cannot be built is markedfailed(body and headers cleared, as_finishdoes), logged without its content, and the pass continues with the next row. This is the most important part. - Header cleaning (
mail/headers.py):cleanfolds 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). - Names: project names (and any other name that reaches a mail header) refuse Cc, Zl and Zp characters, as
routes/projects.pyNOT_PLAINdoes for checklists. Update docs/api.md if a 422 reason is added. - Already stuck rows: a migration or a startup step frees rows left in
sendingfrom before the fix, so they are retried or failed under the new rule. Explain the choice in the PR. - 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.