Skip to content

Commit 1efb9f3

Browse files
author
Jayce Fayne
committed
increase limit
1 parent b3f67b0 commit 1efb9f3

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ impl<'a> Iterator for PartsIterator<'a> {
925925
/// assert_eq!(dateparse(parsed.headers.get_first_value("Date").unwrap().as_str()).unwrap(), 1475417182);
926926
/// ```
927927
pub fn parse_mail(raw_data: &[u8]) -> Result<ParsedMail<'_>, MailParseError> {
928-
parse_mail_recursive(raw_data, false, u8::MAX)
928+
parse_mail_recursive(raw_data, false, RECURSION_LIMIT)
929929
}
930930

931931
/// Strips LF or CRLF if there is one at the end of the string raw_data[ix_start..ix].
@@ -942,10 +942,15 @@ fn strip_trailing_crlf(raw_data: &[u8], ix_start: usize, mut ix: usize) -> usize
942942
ix
943943
}
944944

945+
#[cfg(debug_assertions)]
946+
const RECURSION_LIMIT: u16 = 1000;
947+
#[cfg(not(debug_assertions))]
948+
const RECURSION_LIMIT: u16 = 3000;
949+
945950
fn parse_mail_recursive(
946951
raw_data: &[u8],
947952
in_multipart_digest: bool,
948-
depth: u8,
953+
depth: u16,
949954
) -> Result<ParsedMail<'_>, MailParseError> {
950955
let (headers, ix_body) = parse_headers(raw_data)?;
951956
let ctype = headers

0 commit comments

Comments
 (0)