diff --git a/src/libraries/System.Net.Http/src/Internal/Mail/MailAddressParser.cs b/src/libraries/System.Net.Http/src/Internal/Mail/MailAddressParser.cs index 4dc40953442..8f65d346459 100644 --- a/src/libraries/System.Net.Http/src/Internal/Mail/MailAddressParser.cs +++ b/src/libraries/System.Net.Http/src/Internal/Mail/MailAddressParser.cs @@ -223,7 +223,7 @@ namespace System.Net.Mail // before the next address. if (index >= 0 && !( - MailBnfHelper.Whitespace.Contains(data[index]) // < local@domain > + MailBnfHelper.IsAllowedWhiteSpace(data[index]) // < local@domain > || data[index] == MailBnfHelper.EndComment // <(comment)local@domain> || (expectAngleBracket && data[index] == MailBnfHelper.StartAngleBracket) // || (expectMultipleAddresses && data[index] == MailBnfHelper.Comma) // local@dom,local@dom diff --git a/src/libraries/System.Net.Http/src/Internal/Mail/MailBnfHelper.cs b/src/libraries/System.Net.Http/src/Internal/Mail/MailBnfHelper.cs index 0362230a3b6..b195645e417 100644 --- a/src/libraries/System.Net.Http/src/Internal/Mail/MailBnfHelper.cs +++ b/src/libraries/System.Net.Http/src/Internal/Mail/MailBnfHelper.cs @@ -47,18 +47,6 @@ namespace System.Net.Mime internal static readonly char EndSquareBracket = ']'; internal static readonly char Comma = ','; internal static readonly char Dot = '.'; - internal static readonly IList Whitespace = CreateAllowedWhitespace(); - - private static List CreateAllowedWhitespace() - { - // all allowed whitespace characters - var whitespace = new List(4); - whitespace.Add(Tab); - whitespace.Add(Space); - whitespace.Add(CR); - whitespace.Add(LF); - return whitespace; - } // NOTE: See RFC 2822 for more detail. By default, every value in the array is false and only // those values which are allowed in that particular set are then set to true. The numbers @@ -397,6 +385,12 @@ namespace System.Net.Mime return true; } + internal static bool IsAllowedWhiteSpace(char c) + { + // all allowed whitespace characters + return c == Tab || c == Space || c == CR || c == LF; + } + internal static bool HasCROrLF(string data) { for (int i = 0; i < data.Length; i++)