Escape LMTP data
This commit is contained in:
parent
599480c3d3
commit
0e3cfe536f
2 changed files with 8 additions and 2 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -28,7 +28,7 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aerogramme"
|
name = "aerogramme"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"argon2",
|
"argon2",
|
||||||
|
|
|
@ -16,7 +16,7 @@ use tokio::select;
|
||||||
use tokio::sync::watch;
|
use tokio::sync::watch;
|
||||||
use tokio_util::compat::*;
|
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 smtp_server::{reply, Config, ConnectionMetadata, Decision, MailMetadata};
|
||||||
|
|
||||||
use crate::config::*;
|
use crate::config::*;
|
||||||
|
@ -181,6 +181,12 @@ impl Config for LmtpServer {
|
||||||
return err_response_stream(meta, format!("io error: {}", e));
|
return err_response_stream(meta, format!("io error: {}", e));
|
||||||
}
|
}
|
||||||
reader.complete();
|
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) {
|
let encrypted_message = match EncryptedMessage::new(text) {
|
||||||
Ok(x) => Arc::new(x),
|
Ok(x) => Arc::new(x),
|
||||||
|
|
Loading…
Reference in a new issue