summaryrefslogtreecommitdiffstats
path: root/SendGrid
diff options
context:
space:
mode:
authorShawn A. Luce <git@saluce.com>2014-05-23 01:24:03 -0500
committerShawn A. Luce <git@saluce.com>2014-05-23 01:24:03 -0500
commitd6605b353c28fc7309f5f26b1d00e0fbaab2dd2b (patch)
tree643cdddf17ec636e4a7e6f54db63efab7fdfe718 /SendGrid
parentc397b905d338b528e0534a2235d7b2f757f16b4d (diff)
downloadsendgrid-csharp-d6605b353c28fc7309f5f26b1d00e0fbaab2dd2b.zip
sendgrid-csharp-d6605b353c28fc7309f5f26b1d00e0fbaab2dd2b.tar.gz
sendgrid-csharp-d6605b353c28fc7309f5f26b1d00e0fbaab2dd2b.tar.bz2
Fixed regular expressions for unsubscribe and template filters.
Diffstat (limited to 'SendGrid')
-rw-r--r--SendGrid/SendGridMail/SendGrid.cs14
1 files changed, 7 insertions, 7 deletions
diff --git a/SendGrid/SendGridMail/SendGrid.cs b/SendGrid/SendGridMail/SendGrid.cs
index 8b48774..6ce6c81 100644
--- a/SendGrid/SendGridMail/SendGrid.cs
+++ b/SendGrid/SendGridMail/SendGrid.cs
@@ -15,11 +15,11 @@ namespace SendGrid
#region constants/vars
//apps list and settings
- private const String ReText = @"<\%\s*\%>";
- private const String ReHtml = @"<\%\s*[^\s]+\s*\%>";
private static readonly Dictionary<String, String> Filters = InitializeFilters();
private readonly MailMessage _message;
-
+ private static readonly Regex TemplateTest = new Regex(@"<%\s*body\s*%>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
+ private static readonly Regex TextUnsubscribeTest = new Regex(@"<%\s*%>", RegexOptions.Compiled);
+ private static readonly Regex HtmlUnsubscribeTest = new Regex(@"<%\s*([^\s%]+\s?)+\s*%>", RegexOptions.Compiled);
#endregion
#region Initialization and Constructors
@@ -332,12 +332,12 @@ namespace SendGrid
{
var filter = Filters["Unsubscribe"];
- if (!Regex.IsMatch(text, ReText))
+ if (!TextUnsubscribeTest.IsMatch(text))
{
throw new Exception("Missing substitution replacementTag in text");
}
- if (!Regex.IsMatch(html, ReHtml))
+ if (!HtmlUnsubscribeTest.IsMatch(html))
{
throw new Exception("Missing substitution replacementTag in html");
}
@@ -381,9 +381,9 @@ namespace SendGrid
{
var filter = Filters["Template"];
- if (!Regex.IsMatch(html, ReHtml))
+ if (!TemplateTest.IsMatch(html))
{
- throw new Exception("Missing substitution replacementTag in html");
+ throw new Exception("Missing <% body %> tag in template HTML");
}
Header.EnableFilter(filter);