diff options
| author | Mroik <mroik@delayed.space> | 2026-04-11 05:22:40 +0200 |
|---|---|---|
| committer | Mroik <mroik@delayed.space> | 2026-04-13 06:56:11 +0200 |
| commit | 040279c48c893aae28de6fe5522f5cdc1f020eb3 (patch) | |
| tree | 45ecd458c749f98773012f159c84b17866477721 /src/smtp_server.rs | |
| parent | 203f02b88e75a9b604b27922aecaceb31c44d20a (diff) | |
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 <mroik@delayed.space>
Diffstat (limited to 'src/smtp_server.rs')
| -rw-r--r-- | src/smtp_server.rs | 7 |
1 files changed, 7 insertions, 0 deletions
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; } |
