fix(email): Fix mimebody DKIM body-hash computation
This commit is contained in:
committed by
Paolo Barbolini
parent
f2c94cdf4d
commit
f7849078b8
@@ -17,6 +17,15 @@ pub(super) enum Part {
|
||||
Multi(MultiPart),
|
||||
}
|
||||
|
||||
impl Part {
|
||||
pub(super) fn body_raw(&self) -> Vec<u8> {
|
||||
match self {
|
||||
Part::Single(part) => part.body_raw(),
|
||||
Part::Multi(part) => part.body_raw(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl EmailFormat for Part {
|
||||
fn format(&self, out: &mut Vec<u8>) {
|
||||
match self {
|
||||
@@ -132,6 +141,13 @@ impl SinglePart {
|
||||
self.format(&mut out);
|
||||
out
|
||||
}
|
||||
|
||||
pub(super) fn body_raw(&self) -> Vec<u8> {
|
||||
let mut out = Vec::new();
|
||||
out.extend_from_slice(&self.body);
|
||||
out.extend_from_slice(b"\r\n");
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
impl EmailFormat for SinglePart {
|
||||
@@ -373,6 +389,24 @@ impl MultiPart {
|
||||
self.format(&mut out);
|
||||
out
|
||||
}
|
||||
|
||||
pub(super) fn body_raw(&self) -> Vec<u8> {
|
||||
let mut out = Vec::new();
|
||||
|
||||
let boundary = self.boundary();
|
||||
|
||||
for part in &self.parts {
|
||||
out.extend_from_slice(b"--");
|
||||
out.extend_from_slice(boundary.as_bytes());
|
||||
out.extend_from_slice(b"\r\n");
|
||||
part.format(&mut out);
|
||||
}
|
||||
|
||||
out.extend_from_slice(b"--");
|
||||
out.extend_from_slice(boundary.as_bytes());
|
||||
out.extend_from_slice(b"--\r\n");
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
impl EmailFormat for MultiPart {
|
||||
|
||||
@@ -525,7 +525,7 @@ impl Message {
|
||||
pub(crate) fn body_raw(&self) -> Vec<u8> {
|
||||
let mut out = Vec::new();
|
||||
match &self.body {
|
||||
MessageBody::Mime(p) => p.format(&mut out),
|
||||
MessageBody::Mime(p) => out = p.body_raw(),
|
||||
MessageBody::Raw(r) => out.extend_from_slice(r),
|
||||
};
|
||||
out.extend_from_slice(b"\r\n");
|
||||
|
||||
Reference in New Issue
Block a user