DSN updates.

This commit is contained in:
Mauro D 2023-01-05 18:28:02 +00:00
parent dc9071ae3c
commit 25cb048f4d
3 changed files with 14 additions and 11 deletions

View file

@ -44,7 +44,7 @@ pub struct MailFrom<T> {
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct RcptTo<T> { pub struct RcptTo<T> {
pub address: T, pub address: T,
pub orcpt: Option<(T, T)>, pub orcpt: Option<T>,
pub rrvs: i64, pub rrvs: i64,
pub flags: u64, pub flags: u64,
} }

View file

@ -103,6 +103,12 @@ pub(crate) const ORCPT: u128 = (b'O' as u128)
| (b'C' as u128) << 16 | (b'C' as u128) << 16
| (b'P' as u128) << 24 | (b'P' as u128) << 24
| (b'T' as u128) << 32; | (b'T' as u128) << 32;
pub(crate) const RFC822: u64 = (b'R' as u64)
| (b'F' as u64) << 8
| (b'C' as u64) << 16
| (b'8' as u64) << 24
| (b'2' as u64) << 32
| (b'2' as u64) << 40;
pub(crate) const RET: u128 = (b'R' as u128) | (b'E' as u128) << 8 | (b'T' as u128) << 16; pub(crate) const RET: u128 = (b'R' as u128) | (b'E' as u128) << 8 | (b'T' as u128) << 16;
pub(crate) const ENVID: u128 = (b'E' as u128) pub(crate) const ENVID: u128 = (b'E' as u128)
| (b'N' as u128) << 8 | (b'N' as u128) << 8

View file

@ -881,7 +881,7 @@ impl<'x, 'y> Rfc5321Parser<'x, 'y> {
} }
ENVID if self.stop_char == b'=' => { ENVID if self.stop_char == b'=' => {
let env_id = self.xtext()?; let env_id = self.xtext()?;
if self.stop_char.is_ascii_whitespace() && !env_id.is_empty() { if self.stop_char.is_ascii_whitespace() && (1..=100).contains(&env_id.len()) {
params.env_id = env_id.into(); params.env_id = env_id.into();
} else { } else {
self.seek_lf()?; self.seek_lf()?;
@ -1032,17 +1032,14 @@ impl<'x, 'y> Rfc5321Parser<'x, 'y> {
} }
}, },
ORCPT if self.stop_char == b'=' => { ORCPT if self.stop_char == b'=' => {
let addr_type = self.seek_char(b';')?; let v = self.hashed_value()?;
if self.stop_char != b';' { if v != RFC822 || self.stop_char != b';' {
self.seek_lf()?; self.seek_lf()?;
return Err(Error::InvalidParameter { param: "ORCPT" }); return Err(Error::InvalidParameter { param: "ORCPT" });
} }
let addr = self.xtext()?; let addr = self.xtext()?;
if self.stop_char.is_ascii_whitespace() if self.stop_char.is_ascii_whitespace() && (1..=500).contains(&addr.len()) {
&& !addr_type.is_empty() params.orcpt = addr.into();
&& !addr.is_empty()
{
params.orcpt = (addr_type, addr).into();
} else { } else {
self.seek_lf()?; self.seek_lf()?;
return Err(Error::InvalidParameter { param: "ORCPT" }); return Err(Error::InvalidParameter { param: "ORCPT" });
@ -1802,7 +1799,7 @@ mod tests {
Ok(Request::Rcpt { Ok(Request::Rcpt {
to: RcptTo { to: RcptTo {
address: "".to_string(), address: "".to_string(),
orcpt: ("rfc822".to_string(), "Bob@Example.COM".to_string()).into(), orcpt: "Bob@Example.COM".to_string().into(),
..Default::default() ..Default::default()
}, },
}), }),
@ -1812,7 +1809,7 @@ mod tests {
Ok(Request::Rcpt { Ok(Request::Rcpt {
to: RcptTo { to: RcptTo {
address: "".to_string(), address: "".to_string(),
orcpt: ("rfc822".to_string(), "George @Tax- ME .GOV".to_string()).into(), orcpt: "George @Tax- ME .GOV".to_string().into(),
..Default::default() ..Default::default()
}, },
}), }),