diff --git a/src/NAnt.Core/Tasks/MailTask.cs b/src/NAnt.Core/Tasks/MailTask.cs index b5efe4a36..e8ab47025 100644 --- a/src/NAnt.Core/Tasks/MailTask.cs +++ b/src/NAnt.Core/Tasks/MailTask.cs @@ -120,8 +120,8 @@ public class MailTask : Task { [TaskAttribute("replyto")] public string ReplyTo { - get { return _replyTo; } - set { _replyTo = value; } + get { return _replyTo; } + set { _replyTo = value; } } /// @@ -325,15 +325,15 @@ public MailFormat Format if (!String.IsNullOrEmpty(ReplyTo)) { #if NET_4_0 - MailAddressCollection replyAddrs = ParseAddresses(ReplyTo); - - if (replyAddrs.Count > 0) { - foreach (MailAddress replyAddr in replyAddrs) { - mailMessage.ReplyToList.Add(replyAddr); - } - } + MailAddressCollection replyAddrs = ParseAddresses(ReplyTo); + + if (replyAddrs.Count > 0) { + foreach (MailAddress replyAddr in replyAddrs) { + mailMessage.ReplyToList.Add(replyAddr); + } + } #else - mailMessage.ReplyTo = ConvertStringToMailAddress(ReplyTo); + mailMessage.ReplyTo = ConvertStringToMailAddress(ReplyTo); #endif } @@ -535,57 +535,57 @@ private MailAddress ConvertStringToMailAddress(string address) // String array containing all of the regex strings used to // locate the email address in the parameter string. - string[] validators = new string[] - { - // Format: Full Name - @"^(?.+)\s<(?[^<>\(\)\s]+@[^<>\(\)\s]+\.[^<>\(\)\s]+)>$", - - // Format: Full Name - @"^<(?[^<>\(\)\s]+@[^<>\(\)\s]+\.[^\s]+)>\s(?.+)$", - - // Format: (Full Name) address@abcxyz.com - @"^\((?.+)\)\s(?[^<>\(\)\s]+@[^<>\(\)\s]+\.[^<>\(\)\s]+)$", - - // Format: address@abcxyz.com (Full Name) - @"^(?[^<>\(\)\s]+@[^<>\(\)\s]+\.[^\s]+)\s\((?.+)\)$", - - // Format: address@abcxyz.com - @"(?[^<>\(\)\s]+@[^<>\(\)\s]+\.[^<>\(\)\s]+)" - }; - - // Loop through each regex string to find the one that the - // email address matches. - foreach (string reg in validators) - { - // Create the regex object and try to match - // the email address with the current regex - // string. - Regex currentRegex = new Regex(reg); - Match email = currentRegex.Match(escAddress); - - // If the match is considered successful, return - // a new MailAddress object. If a name was - // paired with an email address in the parameter, - // add it to the MailAddress object that is returned. - if (email.Success) - { - if (email.Groups["fullname"].Success) - { - return new MailAddress( - email.Groups["email"].Value.Trim(), - email.Groups["fullname"].Value.Trim()); - } - - return new MailAddress(email.Groups["email"].Value.Trim()); - } - } - - // If none of the regex strings matches the address parameter, - // throw a build exception. - throw new BuildException( - String.Format(CultureInfo.InvariantCulture, - "{0} is not a recognized email address", - address)); + string[] validators = new string[] + { + // Format: Full Name + @"^(?.+)\s<(?[^<>\(\)\s]+@[^<>\(\)\s]+\.[^<>\(\)\s]+)>$", + + // Format: Full Name + @"^<(?[^<>\(\)\s]+@[^<>\(\)\s]+\.[^\s]+)>\s(?.+)$", + + // Format: (Full Name) address@abcxyz.com + @"^\((?.+)\)\s(?[^<>\(\)\s]+@[^<>\(\)\s]+\.[^<>\(\)\s]+)$", + + // Format: address@abcxyz.com (Full Name) + @"^(?[^<>\(\)\s]+@[^<>\(\)\s]+\.[^\s]+)\s\((?.+)\)$", + + // Format: address@abcxyz.com + @"(?[^<>\(\)\s]+@[^<>\(\)\s]+\.[^<>\(\)\s]+)" + }; + + // Loop through each regex string to find the one that the + // email address matches. + foreach (string reg in validators) + { + // Create the regex object and try to match + // the email address with the current regex + // string. + Regex currentRegex = new Regex(reg); + Match email = currentRegex.Match(escAddress); + + // If the match is considered successful, return + // a new MailAddress object. If a name was + // paired with an email address in the parameter, + // add it to the MailAddress object that is returned. + if (email.Success) + { + if (email.Groups["fullname"].Success) + { + return new MailAddress( + email.Groups["email"].Value.Trim(), + email.Groups["fullname"].Value.Trim()); + } + + return new MailAddress(email.Groups["email"].Value.Trim()); + } + } + + // If none of the regex strings matches the address parameter, + // throw a build exception. + throw new BuildException( + String.Format(CultureInfo.InvariantCulture, + "{0} is not a recognized email address", + address)); } #endregion Private Instance Methods diff --git a/src/NAnt.Core/Util/StringUtils.cs b/src/NAnt.Core/Util/StringUtils.cs index f33cd2ceb..8d5aa66e1 100644 --- a/src/NAnt.Core/Util/StringUtils.cs +++ b/src/NAnt.Core/Util/StringUtils.cs @@ -172,11 +172,11 @@ public sealed class StringUtils { /// public static string HtmlDecode(string value) { - return value.Replace(""", "\"") - .Replace("&", "&") - .Replace("'", "'") - .Replace("<", "<") - .Replace(">", ">"); + return value.Replace(""", "\"") + .Replace("&", "&") + .Replace("'", "'") + .Replace("<", "<") + .Replace(">", ">"); } #endregion Public Static Methods