Skip to content

Commit 10f65f7

Browse files
authored
Merge pull request #22 from madsoulswe/issue-21
Disable check if Request.Form i missing
2 parents ec0149f + 7285688 commit 10f65f7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Our.Umbraco.Honeypot.Core/HoneypotService.cs

+11
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public bool IsTrapped(HttpContext httpContext, out bool fieldTrap, out bool time
3838
{
3939
fieldTrap = false;
4040
timeTrap = false;
41+
42+
if (httpContext.Request.ContentType != "application/x-www-form-urlencoded" && httpContext.Request.ContentType != "multipart/form-data")
43+
{
44+
return false;
45+
}
4146

4247
if (!httpContext.Items.Contains(HttpContextItemName) || (httpContext.Items[HttpContextItemName] is bool value) == false)
4348
{
@@ -91,6 +96,12 @@ public bool IsTrapped(HttpContext httpContext, out bool fieldTrap, out bool time
9196
fieldTrap = false;
9297
timeTrap = false;
9398

99+
if (!httpContext.Request.HasFormContentType)
100+
{
101+
//Fallback when Request.Form is missing (Umbraco Forms API)
102+
return false;
103+
}
104+
94105
if (httpContext.Items.TryGetValue(HttpContextItemName, out object? value) == false)
95106
{
96107

0 commit comments

Comments
 (0)