From 040279c48c893aae28de6fe5522f5cdc1f020eb3 Mon Sep 17 00:00:00 2001 From: Mroik Date: Sat, 11 Apr 2026 05:22:40 +0200 Subject: Add a note on email encodings Leave a note for future devs that the server might receive an email with an encoding different from ASCII or UTF-8. This can be problematic as String accepts only UTF-8 valid strings. In TODO when I say "handle non UTF-8 encodings", I think it would be totally ok to just disregard anything that isn't UTF-8 and return a "rejected for policy" error to the MTA. Otherwise we'll just have to put `encoding_rs` in the mix. Signed-off-by: Mroik --- src/smtp_server.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/smtp_server.rs b/src/smtp_server.rs index 2805081..b4f59db 100644 --- a/src/smtp_server.rs +++ b/src/smtp_server.rs @@ -85,6 +85,13 @@ impl SessionHandler { loop { buffer.clear(); + // Technically emails could use any arbitrary encoding, not necessarily ASCII or UTF-8. + // If such encoding is ever encountered it would error on this line. + // + // For now we won't bother to check as it is unlikely, but it should be handled before + // deploying in production. + // + // TODO: Handle non UTF-8 encoding. if reader.read_line(&mut buffer).await? == 0 { break; } -- cgit v1.3