From 51192342a63a7a6e67679e7e831c09e37ecf00ad Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Sun, 24 Feb 2019 15:03:38 +0100 Subject: [PATCH] view: fix template throwing exception on edge case (#549) If a user has a comment under the edit time limit in a comment locked torrent, but also are still affected by the new account CAPTCHA cooldown, the template would throw an error as we tried to getattr on a None object (namely, the comment_form). To fix this, we also need to check around the edit form whether the comment_form exists. --- nyaa/templates/view.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nyaa/templates/view.html b/nyaa/templates/view.html index bc41bd1..027592e 100644 --- a/nyaa/templates/view.html +++ b/nyaa/templates/view.html @@ -175,7 +175,7 @@
{# Escape newlines into html entities because CF strips blank newlines #}
{{- comment.text | escape | replace('\r\n', '\n') | replace('\n', ' '|safe) -}}
- {% if g.user.id == comment.user_id %} + {% if g.user.id == comment.user_id and comment_form %}
{{ comment_form.csrf_token }}