Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle bad form json as BadRequest #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion collective/honeypot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from collective.honeypot.config import ALLOWLISTED_ACTIONS
from collective.honeypot.config import ALLOWLISTED_START
from copy import deepcopy
from plone.restapi.exceptions import DeserializationError
from zExceptions import BadRequest
from zExceptions import Forbidden
from zope.globalrequest import getRequest
from zope.i18n import translate
Expand Down Expand Up @@ -149,7 +151,10 @@ def check_post(request):
if allowlisted(action):
logger.debug("Action allowlisted: %s.", action)
return
form = get_form(request)
try:
form = get_form(request)
except DeserializationError as e:
raise BadRequest(e)
if action in EXTRA_PROTECTED_ACTIONS:
result = found_honeypot(form, required=True)
else:
Expand Down
Loading