diff --git a/zds/forum/views.py b/zds/forum/views.py index 0db52095d7..4615d1eadf 100644 --- a/zds/forum/views.py +++ b/zds/forum/views.py @@ -151,9 +151,13 @@ def topic(request, topic_pk, topic_slug): # The category list is needed to move threads categories = Category.objects.all() - try: - page_nbr = int(request.GET["page"]) - except KeyError: + if "page" in request.GET: + try: + page_nbr = int(request.GET["page"]) + except: + # problem in variable format + raise Http404 + else: page_nbr = 1 try: posts = paginator.page(page_nbr) @@ -233,7 +237,8 @@ def new(request): try: forum_pk = request.GET["forum"] - except KeyError: + except: + # problem in variable format raise Http404 forum = get_object_or_404(Forum, pk=forum_pk) if not forum.can_read(request.user): @@ -344,7 +349,8 @@ def move_topic(request): raise PermissionDenied try: topic_pk = request.GET["sujet"] - except KeyError: + except: + # problem in variable format raise Http404 forum = get_object_or_404(Forum, pk=request.POST["forum"]) if not forum.can_read(request.user): @@ -374,12 +380,18 @@ def edit(request): try: topic_pk = request.POST["topic"] - except KeyError: + except: + # problem in variable format raise Http404 - try: - page = int(request.POST["page"]) - except KeyError: + if "page" in request.POST: + try: + page = int(request.POST["page"]) + except: + #problem in variable format + raise Http404 + else: page = 1 + data = request.POST resp = {} g_topic = get_object_or_404(Topic, pk=topic_pk) @@ -409,7 +421,8 @@ def edit(request): if "move" in data: try: forum_pk = int(request.POST["move_target"]) - except KeyError: + except: + # problem in variable format raise Http404 forum = get_object_or_404(Forum, pk=forum_pk) g_topic.forum = forum @@ -432,7 +445,8 @@ def answer(request): try: topic_pk = request.GET["sujet"] - except KeyError: + except: + # problem in variable format raise Http404 # Retrieve current topic. @@ -589,7 +603,8 @@ def edit_post(request): try: post_pk = request.GET["message"] - except KeyError: + except: + # problem in variable format raise Http404 post = get_object_or_404(Post, pk=post_pk) if not post.topic.forum.can_read(request.user): @@ -715,7 +730,8 @@ def useful_post(request): try: post_pk = request.GET["message"] - except KeyError: + except: + # problem in variable format raise Http404 post = get_object_or_404(Post, pk=post_pk) @@ -741,7 +757,8 @@ def unread_post(request): try: post_pk = request.GET["message"] - except KeyError: + except: + # problem in variable format raise Http404 post = get_object_or_404(Post, pk=post_pk) @@ -775,7 +792,8 @@ def like_post(request): try: post_pk = request.GET["message"] - except KeyError: + except: + # problem in variable format raise Http404 resp = {} post = get_object_or_404(Post, pk=post_pk) @@ -822,7 +840,8 @@ def dislike_post(request): try: post_pk = request.GET["message"] - except KeyError: + except: + # problem in variable format raise Http404 resp = {} post = get_object_or_404(Post, pk=post_pk)