-
-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added *MimeParser tests for EOF where subpart headers should begin
- Loading branch information
Showing
4 changed files
with
184 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -941,6 +941,94 @@ This is the message body. | |
} | ||
} | ||
|
||
[Test] | ||
public void TestMultipartTruncatedImmediatelyAfterBoundary () | ||
{ | ||
string text = @"From: [email protected] | ||
To: [email protected] | ||
Subject: test of multipart boundary w/o trailing newline | ||
Date: Tue, 12 Nov 2013 09:12:42 -0500 | ||
MIME-Version: 1.0 | ||
Message-ID: <[email protected]> | ||
X-Mailer: Microsoft Office Outlook 12.0 | ||
Content-Type: multipart/mixed; | ||
boundary=""----=_NextPart_000_003F_01CE98CE.6E826F90"" | ||
------=_NextPart_000_003F_01CE98CE.6E826F90 | ||
".Replace ("\r\n", "\n"); | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text), false)) { | ||
var parser = new ExperimentalMimeParser (stream, MimeFormat.Entity); | ||
var message = parser.ParseMessage (); | ||
|
||
Assert.That (message.Body, Is.InstanceOf<Multipart> (), "Expected top-level to be a multipart"); | ||
var multipart = (Multipart) message.Body; | ||
Assert.That (multipart.Count, Is.EqualTo (1)); | ||
Assert.That (multipart[0], Is.InstanceOf<TextPart> (), "Expected first child of the multipart to be text/plain"); | ||
var body = (TextPart) multipart[0]; | ||
|
||
Assert.That (body.Text, Is.EqualTo (string.Empty)); | ||
} | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text.Replace ("\n", "\r\n")), false)) { | ||
var parser = new ExperimentalMimeParser (stream, MimeFormat.Entity); | ||
var message = parser.ParseMessage (); | ||
|
||
Assert.That (message.Body, Is.InstanceOf<Multipart> (), "Expected top-level to be a multipart"); | ||
var multipart = (Multipart) message.Body; | ||
Assert.That (multipart.Count, Is.EqualTo (1)); | ||
Assert.That (multipart[0], Is.InstanceOf<TextPart> (), "Expected first child of the multipart to be text/plain"); | ||
var body = (TextPart) multipart[0]; | ||
|
||
Assert.That (body.Text, Is.EqualTo (string.Empty)); | ||
} | ||
} | ||
|
||
[Test] | ||
public async Task TestMultipartTruncatedImmediatelyAfterBoundaryAsync () | ||
{ | ||
string text = @"From: [email protected] | ||
To: [email protected] | ||
Subject: test of multipart boundary w/o trailing newline | ||
Date: Tue, 12 Nov 2013 09:12:42 -0500 | ||
MIME-Version: 1.0 | ||
Message-ID: <[email protected]> | ||
X-Mailer: Microsoft Office Outlook 12.0 | ||
Content-Type: multipart/mixed; | ||
boundary=""----=_NextPart_000_003F_01CE98CE.6E826F90"" | ||
------=_NextPart_000_003F_01CE98CE.6E826F90 | ||
".Replace ("\r\n", "\n"); | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text), false)) { | ||
var parser = new ExperimentalMimeParser (stream, MimeFormat.Entity); | ||
var message = await parser.ParseMessageAsync (); | ||
|
||
Assert.That (message.Body, Is.InstanceOf<Multipart> (), "Expected top-level to be a multipart"); | ||
var multipart = (Multipart) message.Body; | ||
Assert.That (multipart.Count, Is.EqualTo (1)); | ||
Assert.That (multipart[0], Is.InstanceOf<TextPart> (), "Expected first child of the multipart to be text/plain"); | ||
var body = (TextPart) multipart[0]; | ||
|
||
Assert.That (body.Text, Is.EqualTo (string.Empty)); | ||
} | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text.Replace ("\n", "\r\n")), false)) { | ||
var parser = new ExperimentalMimeParser (stream, MimeFormat.Entity); | ||
var message = await parser.ParseMessageAsync (); | ||
|
||
Assert.That (message.Body, Is.InstanceOf<Multipart> (), "Expected top-level to be a multipart"); | ||
var multipart = (Multipart) message.Body; | ||
Assert.That (multipart.Count, Is.EqualTo (1)); | ||
Assert.That (multipart[0], Is.InstanceOf<TextPart> (), "Expected first child of the multipart to be text/plain"); | ||
var body = (TextPart) multipart[0]; | ||
|
||
Assert.That (body.Text, Is.EqualTo (string.Empty)); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TestMultipartBoundaryWithoutTrailingNewline () | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -933,6 +933,94 @@ This is the message body. | |
} | ||
} | ||
|
||
[Test] | ||
public void TestMultipartTruncatedImmediatelyAfterBoundary () | ||
{ | ||
string text = @"From: [email protected] | ||
To: [email protected] | ||
Subject: test of multipart boundary w/o trailing newline | ||
Date: Tue, 12 Nov 2013 09:12:42 -0500 | ||
MIME-Version: 1.0 | ||
Message-ID: <[email protected]> | ||
X-Mailer: Microsoft Office Outlook 12.0 | ||
Content-Type: multipart/mixed; | ||
boundary=""----=_NextPart_000_003F_01CE98CE.6E826F90"" | ||
------=_NextPart_000_003F_01CE98CE.6E826F90 | ||
".Replace ("\r\n", "\n"); | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text), false)) { | ||
var parser = new MimeParser (stream, MimeFormat.Entity); | ||
var message = parser.ParseMessage (); | ||
|
||
Assert.That (message.Body, Is.InstanceOf<Multipart> (), "Expected top-level to be a multipart"); | ||
var multipart = (Multipart) message.Body; | ||
Assert.That (multipart.Count, Is.EqualTo (1)); | ||
Assert.That (multipart[0], Is.InstanceOf<TextPart> (), "Expected first child of the multipart to be text/plain"); | ||
var body = (TextPart) multipart[0]; | ||
|
||
Assert.That (body.Text, Is.EqualTo (string.Empty)); | ||
} | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text.Replace ("\n", "\r\n")), false)) { | ||
var parser = new MimeParser (stream, MimeFormat.Entity); | ||
var message = parser.ParseMessage (); | ||
|
||
Assert.That (message.Body, Is.InstanceOf<Multipart> (), "Expected top-level to be a multipart"); | ||
var multipart = (Multipart) message.Body; | ||
Assert.That (multipart.Count, Is.EqualTo (1)); | ||
Assert.That (multipart[0], Is.InstanceOf<TextPart> (), "Expected first child of the multipart to be text/plain"); | ||
var body = (TextPart) multipart[0]; | ||
|
||
Assert.That (body.Text, Is.EqualTo (string.Empty)); | ||
} | ||
} | ||
|
||
[Test] | ||
public async Task TestMultipartTruncatedImmediatelyAfterBoundaryAsync () | ||
{ | ||
string text = @"From: [email protected] | ||
To: [email protected] | ||
Subject: test of multipart boundary w/o trailing newline | ||
Date: Tue, 12 Nov 2013 09:12:42 -0500 | ||
MIME-Version: 1.0 | ||
Message-ID: <[email protected]> | ||
X-Mailer: Microsoft Office Outlook 12.0 | ||
Content-Type: multipart/mixed; | ||
boundary=""----=_NextPart_000_003F_01CE98CE.6E826F90"" | ||
------=_NextPart_000_003F_01CE98CE.6E826F90 | ||
".Replace ("\r\n", "\n"); | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text), false)) { | ||
var parser = new MimeParser (stream, MimeFormat.Entity); | ||
var message = await parser.ParseMessageAsync (); | ||
|
||
Assert.That (message.Body, Is.InstanceOf<Multipart> (), "Expected top-level to be a multipart"); | ||
var multipart = (Multipart) message.Body; | ||
Assert.That (multipart.Count, Is.EqualTo (1)); | ||
Assert.That (multipart[0], Is.InstanceOf<TextPart> (), "Expected first child of the multipart to be text/plain"); | ||
var body = (TextPart) multipart[0]; | ||
|
||
Assert.That (body.Text, Is.EqualTo (string.Empty)); | ||
} | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text.Replace ("\n", "\r\n")), false)) { | ||
var parser = new MimeParser (stream, MimeFormat.Entity); | ||
var message = await parser.ParseMessageAsync (); | ||
|
||
Assert.That (message.Body, Is.InstanceOf<Multipart> (), "Expected top-level to be a multipart"); | ||
var multipart = (Multipart) message.Body; | ||
Assert.That (multipart.Count, Is.EqualTo (1)); | ||
Assert.That (multipart[0], Is.InstanceOf<TextPart> (), "Expected first child of the multipart to be text/plain"); | ||
var body = (TextPart) multipart[0]; | ||
|
||
Assert.That (body.Text, Is.EqualTo (string.Empty)); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TestMultipartBoundaryWithoutTrailingNewline () | ||
{ | ||
|