-
Couldn't load subscription status.
- Fork 5.2k
Description
Description
If a MailAddress instance is created with a DisplayName that includes embedded double quote characters, the ToString method doesn't properly escape the embedded double quotes.
The ToString method in the repository is currently:
/// <summary>
/// this returns the full address with quoted display name.
/// i.e. "some email address display name" <user@host>
/// if displayname is not provided then this returns only user@host (no angle brackets)
/// </summary>
public override string ToString()
{
if (string.IsNullOrEmpty(DisplayName))
{
return Address;
}
else
{
return "\"" + DisplayName + "\" " + SmtpAddress;
}
}If the DisplayName property includes double quotes, then these are not escaped properly before surrounding the string with additional double quotes.
For example, if the display name is 'Henry "The Fonz" Winkler', when the ToString method is called, the resulting string would be:
\"Henry \"The Fonz\" Winkler\" <someemail@somedomain.com>
but should be:
\"Henry \\\"The Fonz\\\" Winkler\" <someemail@somedomain.com>
Configuration
Tested on .Net Core v2.2, but the source in this repository looks like it is still an issue in the latest version.
Regression?
Not known if this worked correctly on previous versions of .Net Framework / .Net Core