Skip to content

Commit

Permalink
Require a valid number for id redirects (refs DDCZ-2H)
Browse files Browse the repository at this point in the history
  • Loading branch information
Almad committed Mar 22, 2024
1 parent 996b27b commit e9b402a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ddcz/views/legacy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import logging

from django.apps import apps
from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect
from django.http import (
HttpResponseRedirect,
HttpResponsePermanentRedirect,
HttpResponseBadRequest,
)
from django.http.response import HttpResponse
from django.shortcuts import get_object_or_404
from django.urls.base import reverse
Expand Down Expand Up @@ -79,6 +83,11 @@ def legacy_router(request):
page_creation_type = request.GET.get("co", False)
id = request.GET.get("id", False)

try:
id = int(id)
except ValueError:
return HttpBadRequest("id musí být číslo")

# The LEGACY_PLAIN_ROUTER is redirecting basic pages.
# Typically no creative pages are present here.
if page_category in PAGE_TO_VIEW_MAP.keys():
Expand Down

0 comments on commit e9b402a

Please sign in to comment.