From bb49e0ca7496eec5b7147b8057392b64ca323100 Mon Sep 17 00:00:00 2001
From: Chris Lawton <chris.lawton@torchbox.com>
Date: Mon, 13 May 2019 09:44:20 +0100
Subject: [PATCH] pass through markdown to ensure comment is a fully formed
 HTML block

---
 .../activity/templates/activity/include/listing_base.html      | 2 +-
 opentech/apply/funds/templatetags/markdown_tags.py             | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/opentech/apply/activity/templates/activity/include/listing_base.html b/opentech/apply/activity/templates/activity/include/listing_base.html
index b4fc73b95..8f13bc06b 100644
--- a/opentech/apply/activity/templates/activity/include/listing_base.html
+++ b/opentech/apply/activity/templates/activity/include/listing_base.html
@@ -36,7 +36,7 @@
             {% endif %}
 
             {% if editable %}
-                <div class="feed__comment js-comment" data-id="{{activity.id}}" data-comment="{{activity.message|to_markdown}}" data-edit-url="{% url 'funds:api:comments:edit' pk=activity.pk %}">
+                <div class="feed__comment js-comment" data-id="{{activity.id}}" data-comment="{{activity|display_for:request.user|to_markdown}}" data-edit-url="{% url 'funds:api:comments:edit' pk=activity.pk %}">
                     {{ activity|display_for:request.user|submission_links|markdown|bleach }}
                 </div>
 
diff --git a/opentech/apply/funds/templatetags/markdown_tags.py b/opentech/apply/funds/templatetags/markdown_tags.py
index a4e76e648..ac3320885 100644
--- a/opentech/apply/funds/templatetags/markdown_tags.py
+++ b/opentech/apply/funds/templatetags/markdown_tags.py
@@ -13,4 +13,7 @@ def markdown(value):
 
 @register.filter
 def to_markdown(value):
+    # pass through markdown to ensure comment is a
+    # fully formed HTML block
+    value = markdown(value)
     return tomd.convert(value)
-- 
GitLab