diff comments/views.py @ 978:a828e80223d2

Prevent 500 error when previewing no text. Don't call image_check() when there is no data.
author Brian Neal <bgneal@gmail.com>
date Mon, 05 Oct 2015 20:26:14 -0500
parents d260aef91ad7
children 68c3343f3318
line wrap: on
line diff
--- a/comments/views.py	Mon Oct 05 20:20:34 2015 -0500
+++ b/comments/views.py	Mon Oct 05 20:26:14 2015 -0500
@@ -145,10 +145,11 @@
         return HttpResponseBadRequest('No data')
 
     html = site_markup(data)
-    try:
-        image_check(html)
-    except ImageCheckError as ex:
-        html = PREVIEW_UNAVAILABLE.format(ex)
+    if html:
+        try:
+            image_check(html)
+        except ImageCheckError as ex:
+            html = PREVIEW_UNAVAILABLE.format(ex)
 
     return render_to_response('comments/markdown_preview.html', {
         'data': html,