-
-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test case for parsing garbage mime-types in the Content-Type …
…header
- Loading branch information
Showing
2 changed files
with
20 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -819,8 +819,9 @@ public async Task TestEmptyMessageAsync () | |
} | ||
} | ||
|
||
[Test] | ||
public void TestInvalidContentType () | ||
[TestCase ("garbage")] | ||
[TestCase ("!%^#&^!\\t ")] | ||
public void TestInvalidContentType (string mimeType) | ||
{ | ||
string text = @"From: [email protected] | ||
To: [email protected] | ||
|
@@ -829,10 +830,10 @@ public void TestInvalidContentType () | |
MIME-Version: 1.0 | ||
Message-ID: <[email protected]> | ||
X-Mailer: Microsoft Office Outlook 12.0 | ||
Content-Type: garbage; charset=utf-8 | ||
Content-Type: ${mimeType}; charset=utf-8 | ||
This is the message body. | ||
".Replace ("\r\n", "\n"); | ||
".Replace ("${mimeType}", mimeType).Replace ("\r\n", "\n"); | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text), false)) { | ||
var parser = new ExperimentalMimeParser (stream, MimeFormat.Entity); | ||
|
@@ -867,8 +868,9 @@ This is the message body. | |
} | ||
} | ||
|
||
[Test] | ||
public async Task TestInvalidContentTypeAsync () | ||
[TestCase ("garbage")] | ||
[TestCase ("!%^#&^!\\t ")] | ||
public async Task TestInvalidContentTypeAsync (string mimeType) | ||
{ | ||
string text = @"From: [email protected] | ||
To: [email protected] | ||
|
@@ -877,10 +879,10 @@ public async Task TestInvalidContentTypeAsync () | |
MIME-Version: 1.0 | ||
Message-ID: <[email protected]> | ||
X-Mailer: Microsoft Office Outlook 12.0 | ||
Content-Type: garbage; charset=utf-8 | ||
Content-Type: ${mimeType}; charset=utf-8 | ||
This is the message body. | ||
".Replace ("\r\n", "\n"); | ||
".Replace ("${mimeType}", mimeType).Replace ("\r\n", "\n"); | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text), false)) { | ||
var parser = new ExperimentalMimeParser (stream, MimeFormat.Entity); | ||
|
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 |
---|---|---|
|
@@ -833,8 +833,9 @@ public async Task TestEmptyMessageAsync () | |
} | ||
} | ||
|
||
[Test] | ||
public void TestInvalidContentType () | ||
[TestCase ("garbage")] | ||
[TestCase ("!%^#&^!\\t ")] | ||
public void TestInvalidContentType (string mimeType) | ||
{ | ||
string text = @"From: [email protected] | ||
To: [email protected] | ||
|
@@ -843,10 +844,10 @@ public void TestInvalidContentType () | |
MIME-Version: 1.0 | ||
Message-ID: <[email protected]> | ||
X-Mailer: Microsoft Office Outlook 12.0 | ||
Content-Type: garbage; charset=utf-8 | ||
Content-Type: ${mimeType}; charset=utf-8 | ||
This is the message body. | ||
".Replace ("\r\n", "\n"); | ||
".Replace ("${mimeType}", mimeType).Replace ("\r\n", "\n"); | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text), false)) { | ||
var parser = new MimeParser (stream, MimeFormat.Entity); | ||
|
@@ -881,8 +882,9 @@ This is the message body. | |
} | ||
} | ||
|
||
[Test] | ||
public async Task TestInvalidContentTypeAsync () | ||
[TestCase ("garbage")] | ||
[TestCase ("!%^#&^!\\t ")] | ||
public async Task TestInvalidContentTypeAsync (string mimeType) | ||
{ | ||
string text = @"From: [email protected] | ||
To: [email protected] | ||
|
@@ -891,10 +893,10 @@ public async Task TestInvalidContentTypeAsync () | |
MIME-Version: 1.0 | ||
Message-ID: <[email protected]> | ||
X-Mailer: Microsoft Office Outlook 12.0 | ||
Content-Type: garbage; charset=utf-8 | ||
Content-Type: ${mimeType}; charset=utf-8 | ||
This is the message body. | ||
".Replace ("\r\n", "\n"); | ||
".Replace ("${mimeType}", mimeType).Replace ("\r\n", "\n"); | ||
|
||
using (var stream = new MemoryStream (Encoding.ASCII.GetBytes (text), false)) { | ||
var parser = new MimeParser (stream, MimeFormat.Entity); | ||
|