melib: skip mbox `From ` header if present
mbox messages might end up in the parser by mistake, for example by being present in a Maildir store.memfd
parent
3e31c46a74
commit
e4d4cd55d3
|
@ -236,7 +236,13 @@ impl Envelope {
|
|||
pub fn hash(&self) -> EnvelopeHash {
|
||||
self.hash
|
||||
}
|
||||
pub fn populate_headers(&mut self, bytes: &[u8]) -> Result<()> {
|
||||
pub fn populate_headers(&mut self, mut bytes: &[u8]) -> Result<()> {
|
||||
if bytes.starts_with(b"From ") {
|
||||
/* Attempt to recover if message includes the mbox From label as first line */
|
||||
if let Some(offset) = bytes.find(b"\n") {
|
||||
bytes = &bytes[offset + 1..];
|
||||
}
|
||||
}
|
||||
let (headers, body) = match parser::mail(bytes).to_full_result() {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
|
|
Loading…
Reference in New Issue