fix: fail honestly on unreadable TLS modes and mis-sized mail #425

Merged
KofTwentyTwo merged 2 commits from fix/defabricate-tls-and-size into dev 2026-08-15 01:33:15 +00:00
2 Commits
Author SHA1 Message Date
james.maes 98b59b8a98 fix(filter): size counts all body parts and attachments
The NSQL size field was computed from body_plain alone, so an HTML-only
message measured zero bytes and a short note carrying a large attachment
measured only the note. Every size comparison then answered confidently
and wrongly on exactly the mail such rules are written to catch.

size is now the total byte size of the content the store holds: both body
parts plus every attachment payload. Both parts are summed because a
multipart/alternative message genuinely carries both on the wire. Headers
and MIME framing are excluded and documented as excluded -- the raw RFC822
octets are not retained and no column carries their length, so the figure
is a consistent lower bound rather than a guess.

Refs #256
2026-08-14 20:22:58 -05:00
james.maes ce49515892 fix(store): reject unreadable stored TLS modes on account read
tls_mode_from_db coerced any unrecognized imap_tls_mode/smtp_tls_mode
token to ImplicitTls on the path every ordinary account read takes, so a
corrupted or tampered row silently handed callers a transport the operator
never configured -- a STARTTLS account read back as implicit TLS, with no
error and no log.

Parse now fails closed with DatabaseError::Corrupted naming the account,
the column, and the offending value. list_accounts already returned a
Result, so no caller signature changes and no caller panics; get_account
inherits the behaviour through it.

Refs #271
2026-08-14 20:22:53 -05:00