diff --git a/Class Library/ActiveUp.Net.Common/Parser.cs b/Class Library/ActiveUp.Net.Common/Parser.cs index f9db385..fcdd469 100644 --- a/Class Library/ActiveUp.Net.Common/Parser.cs +++ b/Class Library/ActiveUp.Net.Common/Parser.cs @@ -1037,7 +1037,7 @@ public static AddressCollection ParseAddresses(string input) /// public static Address ParseAddress(string input) { - input = input.TrimEnd(';'); + input = (input ?? "").Replace("\"", "").TrimEnd(';'); try { if (!input.Contains("<")) @@ -1045,7 +1045,7 @@ public static Address ParseAddress(string input) Address address = null; - Match displayNameMatch = Regex.Match(input, "(\"?(.+)(\"?(?=\\s?<)|(?=<)))"); + var displayNameMatch = Regex.Match(input, "(\"?(.+)(\"?(?=\\s?<)|(?=<)))"); if (displayNameMatch.Success) address = new Address(input.Replace(displayNameMatch.Value, string.Empty).Trim().Trim(new[] { '<', '>' }), displayNameMatch.Groups[1].Value); else @@ -1054,7 +1054,7 @@ public static Address ParseAddress(string input) CleanupAddress(address); return address; } - catch + catch (Exception) { return new Address { Email = input }; } diff --git a/Class Library/ActiveUp.Net.Tests/Common/ParserTests.cs b/Class Library/ActiveUp.Net.Tests/Common/ParserTests.cs index 9a2f737..6d8bcc3 100644 --- a/Class Library/ActiveUp.Net.Tests/Common/ParserTests.cs +++ b/Class Library/ActiveUp.Net.Tests/Common/ParserTests.cs @@ -107,6 +107,14 @@ public void should_parse_address_with_no_closing_quote_after_display_name() address.Name.ShouldEqual("Display Name only one quote"); } + [Test] + public void should_parse_address_with_invalid_empty_quote() + { + var address = Parser.ParseAddress("\"\" Invoice@dymak.nl\""); + address.Email.ShouldEqual("Invoice@dymak.nl"); + address.Name.ShouldEqual(""); + } + /// /// [discussion:641270] - Created discussion to validate if this test is rigth. ///