melib: fix bug in parser::parts

At a certain point when expecting a line terminator parts() checks for
'\n' but not '\r\n'. This resulted in all multipart attachments coming
from b"\r\n" sources like IMAP having only one part when parsed.
embed
Manos Pitsidianakis 2019-09-26 01:09:11 +03:00
parent 6d40a57a2e
commit c44056a9ff
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 4 additions and 1 deletions

View File

@ -761,7 +761,10 @@ fn parts_f<'a>(input: &'a [u8], boundary: &[u8]) -> IResult<&'a [u8], Vec<&'a [u
}
ret.push(&input[0..end - 2]);
input = &input[end + boundary.len()..];
if input.len() < 2 || input[0] != b'\n' || &input[0..2] == b"--" {
if input.len() < 2
|| (input[0] != b'\n' && &input[0..2] != b"\r\n")
|| &input[0..2] == b"--"
{
break;
}
if input[0] == b'\n' {