diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-02-10 12:11:01 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-02-10 12:11:01 +0100 |
commit | 0e3cfe536f111c1094d530aed0581390e3fbc878 (patch) | |
tree | 3d3adfb66c40fcd005bdf0b64e2c3d78f8659ca1 /src | |
parent | 599480c3d39c4e86dbef130374ed24e7943039c2 (diff) | |
download | aerogramme-0e3cfe536f111c1094d530aed0581390e3fbc878.tar.gz aerogramme-0e3cfe536f111c1094d530aed0581390e3fbc878.zip |
Escape LMTP data
Diffstat (limited to 'src')
-rw-r--r-- | src/lmtp.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lmtp.rs b/src/lmtp.rs index f88ed8f..28c4d51 100644 --- a/src/lmtp.rs +++ b/src/lmtp.rs @@ -16,7 +16,7 @@ use tokio::select; use tokio::sync::watch; use tokio_util::compat::*; -use smtp_message::{Email, EscapedDataReader, Reply, ReplyCode}; +use smtp_message::{Email, EscapedDataReader, DataUnescaper, Reply, ReplyCode}; use smtp_server::{reply, Config, ConnectionMetadata, Decision, MailMetadata}; use crate::config::*; @@ -181,6 +181,12 @@ impl Config for LmtpServer { return err_response_stream(meta, format!("io error: {}", e)); } reader.complete(); + let raw_size = text.len(); + + // Unescape email, shrink it also to remove last dot + let unesc_res = DataUnescaper::new(true).unescape(&mut text); + text.truncate(unesc_res.written); + tracing::debug!(prev_sz=raw_size, new_sz=text.len(), "unescaped"); let encrypted_message = match EncryptedMessage::new(text) { Ok(x) => Arc::new(x), |