Skip to content

Commit

Permalink
Added more MimeParser tests for message/rfc822 handling
Browse files Browse the repository at this point in the history
Also fixed a bug with Content-Length calculations exposed by these tests.
  • Loading branch information
jstedfast committed Sep 4, 2021
1 parent 8bcfbfb commit 11ac9e8
Show file tree
Hide file tree
Showing 3 changed files with 352 additions and 35 deletions.
8 changes: 4 additions & 4 deletions MimeKit/AsyncMimeParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,11 @@ async Task ConstructMessagePartAsync (MessagePart rfc822, MimeEntityEndEventArgs
case BoundaryType.ParentBoundary:
return;
case BoundaryType.ParentEndBoundary:
// ignore "From " boundaries, broken mailers tend to include these...
if (!IsMboxMarker (start)) {
return;
if (options.RespectContentLength && IsMboxMarker (start)) {
// Allow StepHeaders() to decide.
break;
}
break;
return;
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions MimeKit/MimeParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ unsafe bool StepHeaders (byte* inbuf, ref bool scanningFieldName, ref bool check
if (!valid) {
length = inptr - start;

if (format == MimeFormat.Mbox && inputIndex >= contentEnd && length >= 5 && IsMboxMarker (start)) {
if (format == MimeFormat.Mbox && GetOffset ((int) (start - inbuf)) >= contentEnd && length >= 5 && IsMboxMarker (start)) {
// we've found the start of the next message...
inputIndex = (int) (start - inbuf);
state = MimeParserState.Complete;
Expand Down Expand Up @@ -1434,11 +1434,11 @@ unsafe void ConstructMessagePart (MessagePart rfc822, MimeEntityEndEventArgs arg
case BoundaryType.ParentBoundary:
return;
case BoundaryType.ParentEndBoundary:
// ignore "From " boundaries, broken mailers tend to include these...
if (!IsMboxMarker (start)) {
return;
if (options.RespectContentLength && IsMboxMarker (start)) {
// Allow StepHeaders() to decide.
break;
}
break;
return;
}
}

Expand Down
Loading

0 comments on commit 11ac9e8

Please # to comment.