diff --git a/CatherineLynwood/CatherineLynwood.csproj b/CatherineLynwood/CatherineLynwood.csproj
index 1805ea7..8acd696 100644
--- a/CatherineLynwood/CatherineLynwood.csproj
+++ b/CatherineLynwood/CatherineLynwood.csproj
@@ -154,7 +154,7 @@
-
+
@@ -164,7 +164,6 @@
-
diff --git a/CatherineLynwood/Controllers/HomeController.cs b/CatherineLynwood/Controllers/HomeController.cs
index 3effcf1..4edd838 100644
--- a/CatherineLynwood/Controllers/HomeController.cs
+++ b/CatherineLynwood/Controllers/HomeController.cs
@@ -95,8 +95,15 @@ namespace CatherineLynwood.Controllers
[Route("contact-catherine")]
[HttpPost]
+ [ValidateAntiForgeryToken]
public async Task ContactCatherine(Contact contact)
{
+ if (IsLikelySpamContact(contact))
+ {
+ _logger.LogInformation("Discarded likely spam contact submission.");
+ return RedirectToAction("ThankYou");
+ }
+
if (ModelState.IsValid)
{
await _dataAccess.SaveContact(contact, false);
@@ -113,6 +120,29 @@ namespace CatherineLynwood.Controllers
return View(contact);
}
+ private bool IsLikelySpamContact(Contact contact)
+ {
+ var form = Request.HasFormContentType ? Request.Form : null;
+ var website = form?["Website"].ToString();
+ if (!string.IsNullOrWhiteSpace(website))
+ {
+ return true;
+ }
+
+ if (long.TryParse(form?["ContactStartedAt"].ToString(), out var startedAt))
+ {
+ var elapsedSeconds = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - startedAt;
+ if (elapsedSeconds >= 0 && elapsedSeconds < 4)
+ {
+ return true;
+ }
+ }
+
+ var message = contact.Message ?? string.Empty;
+ var linkCount = System.Text.RegularExpressions.Regex.Matches(message, @"https?://|www\.", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Count;
+ return linkCount > 2;
+ }
+
[Route("feed.xml")]
[Route("rss.xml")]
[Route("rss")]
@@ -338,4 +368,4 @@ namespace CatherineLynwood.Controllers
#endregion Private Methods
}
-}
\ No newline at end of file
+}
diff --git a/CatherineLynwood/Views/Home/AboutCatherineLynwood.cshtml b/CatherineLynwood/Views/Home/AboutCatherineLynwood.cshtml
index c76ee7e..9ec30a7 100644
--- a/CatherineLynwood/Views/Home/AboutCatherineLynwood.cshtml
+++ b/CatherineLynwood/Views/Home/AboutCatherineLynwood.cshtml
@@ -21,7 +21,7 @@
Birmingham-born author of gritty, emotionally truthful fiction about women, survival, family secrets, and the fire people carry after everything else has been stripped away.
-
+
Catherine Lynwood
diff --git a/CatherineLynwood/Views/Home/ContactCatherine.cshtml b/CatherineLynwood/Views/Home/ContactCatherine.cshtml
index 7a323cb..7301dfd 100644
--- a/CatherineLynwood/Views/Home/ContactCatherine.cshtml
+++ b/CatherineLynwood/Views/Home/ContactCatherine.cshtml
@@ -17,7 +17,13 @@