From 4faee4928d110e422b30581b1ebb0114c1ae558d Mon Sep 17 00:00:00 2001 From: Remi Date: Wed, 5 Jan 2022 12:07:40 -0500 Subject: [PATCH] fix: Handle non integer values passed to `object_pk` and `replied_to` (#2012) --- mezzanine/generic/templatetags/comment_tags.py | 2 +- mezzanine/generic/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mezzanine/generic/templatetags/comment_tags.py b/mezzanine/generic/templatetags/comment_tags.py index 059d05655d..de858cfb14 100644 --- a/mezzanine/generic/templatetags/comment_tags.py +++ b/mezzanine/generic/templatetags/comment_tags.py @@ -53,7 +53,7 @@ def comment_thread(context, parent): parent_id = parent.id if isinstance(parent, ThreadedComment) else None try: replied_to = int(context["request"].POST["replied_to"]) - except KeyError: + except (KeyError, ValueError): replied_to = 0 context.update( { diff --git a/mezzanine/generic/views.py b/mezzanine/generic/views.py index 908b28fcaf..67b1d6a46b 100644 --- a/mezzanine/generic/views.py +++ b/mezzanine/generic/views.py @@ -84,7 +84,7 @@ def initial_validation(request, prefix): try: model = apps.get_model(*model_data) obj = model.objects.get(id=post_data.get("object_pk", None)) - except (TypeError, ObjectDoesNotExist, LookupError): + except (TypeError, ObjectDoesNotExist, LookupError, ValueError): redirect_url = "/" if redirect_url: if request_is_ajax(request):