forked from jstedfast/MimeKit
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Add] Allow illegal address #COS-125
- Loading branch information
PhucNV9
committed
Mar 12, 2018
1 parent
4e3611e
commit d35d17f
Showing
5 changed files
with
25 additions
and
62 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 |
---|---|---|
|
@@ -190,10 +190,8 @@ public void TestParseMailboxWithIncompleteLocalPart () | |
public void TestParseIncompleteQuotedString () | ||
{ | ||
const string text = "\"This quoted string never ends... oh no!"; | ||
const int tokenIndex = 0; | ||
int errorIndex = text.Length; | ||
|
||
AssertParseFailure (text, false, tokenIndex, errorIndex); | ||
AssertParse (text); | ||
} | ||
|
||
[Test] | ||
|
@@ -279,20 +277,6 @@ public void TestParseMailboxWithUnquotedCommaInName () | |
// default options should parse this as a single mailbox address | ||
addr = InternetAddress.Parse (text); | ||
Assert.AreEqual ("Worthington, Warren", addr.Name); | ||
|
||
// this should fail when we allow mailbox addresses w/o a domain | ||
var options = ParserOptions.Default.Clone (); | ||
options.AllowAddressesWithoutDomain = true; | ||
|
||
try { | ||
addr = InternetAddress.Parse (options, text); | ||
Assert.Fail ("Should not have parsed \"{0}\" with AllowAddressesWithoutDomain = true", text); | ||
} catch (ParseException pex) { | ||
Assert.AreEqual (text.IndexOf (','), pex.TokenIndex, "TokenIndex"); | ||
Assert.AreEqual (text.IndexOf (','), pex.ErrorIndex, "ErrorIndex"); | ||
} catch (Exception ex) { | ||
Assert.Fail ("Should not have thrown {0}", ex.GetType ().Name); | ||
} | ||
} | ||
|
||
[Test] | ||
|
@@ -534,7 +518,9 @@ TestCaseData[] LegacyAddressNotCompliantWithRFC () | |
new TestCaseData ("[email protected]"), | ||
new TestCaseData ("[email protected]"), | ||
new TestCaseData ("[email protected]"), | ||
|
||
new TestCaseData ("!\"#$%&'()[email protected]"), | ||
new TestCaseData ("!\"#$%&'\"()[email protected]"), | ||
new TestCaseData ("!\"#$%&'\"=\"@amimap.access.co.jp"), | ||
// More not compliant with RFC | ||
// Does not correspond now. | ||
//new TestCaseData ("アドレス <aa\"[email protected]>"), | ||
|
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 |
---|---|---|
|
@@ -260,10 +260,8 @@ public void TestParseMailboxWithIncompleteLocalPart () | |
public void TestParseIncompleteQuotedString () | ||
{ | ||
const string text = "\"This quoted string never ends... oh no!"; | ||
const int tokenIndex = 0; | ||
int errorIndex = text.Length; | ||
|
||
AssertParseFailure (text, false, tokenIndex, errorIndex); | ||
AssertParse (text); | ||
} | ||
|
||
[Test] | ||
|
@@ -360,20 +358,6 @@ public void TestParseMailboxWithUnquotedCommaInName () | |
// default options should parse this as a single mailbox address | ||
mailbox = MailboxAddress.Parse (text); | ||
Assert.AreEqual ("Worthington, Warren", mailbox.Name); | ||
|
||
// this should fail when we allow mailbox addresses w/o a domain | ||
var options = ParserOptions.Default.Clone (); | ||
options.AllowAddressesWithoutDomain = true; | ||
|
||
try { | ||
mailbox = MailboxAddress.Parse (options, text); | ||
Assert.Fail ("Should not have parsed \"{0}\" with AllowAddressesWithoutDomain = true", text); | ||
} catch (ParseException pex) { | ||
Assert.AreEqual (text.IndexOf (','), pex.TokenIndex, "TokenIndex"); | ||
Assert.AreEqual (text.IndexOf (','), pex.ErrorIndex, "ErrorIndex"); | ||
} catch (Exception ex) { | ||
Assert.Fail ("Should not have thrown {0}", ex.GetType ().Name); | ||
} | ||
} | ||
|
||
[Test] | ||
|
@@ -565,11 +549,6 @@ public void TestParseMailboxWithUnbalancedQuotes () | |
const string text = "\"Joe <[email protected]>"; | ||
|
||
AssertParse (text); | ||
|
||
AssertParseFailure (text, false, 0, text.Length, RfcComplianceMode.Strict); | ||
|
||
// for coverage | ||
AssertParseFailure (" \"", false, 1, 2, RfcComplianceMode.Loose); | ||
} | ||
|
||
[Test] | ||
|
@@ -695,7 +674,9 @@ TestCaseData[] LegacyAddressNotCompliantWithRFC () | |
new TestCaseData ("[email protected]"), | ||
new TestCaseData ("[email protected]"), | ||
new TestCaseData ("[email protected]"), | ||
|
||
new TestCaseData ("!\"#$%&'()[email protected]"), | ||
new TestCaseData ("!\"#$%&'\"()[email protected]"), | ||
new TestCaseData ("!\"#$%&'\"=\"@amimap.access.co.jp"), | ||
// More not compliant with RFC | ||
// Does not correspond now. | ||
//new TestCaseData ("アドレス <aa\"[email protected]>"), | ||
|
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