mirror of https://github.com/zulip/zulip.git
bugdown: Allow caller of convert to tell whether we succeeded.
(imported from commit 9e3cab73e0d9e9ad31ba770210e535584cca3bb2)
This commit is contained in:
parent
a22c5e63a8
commit
2f022ebb34
|
@ -417,15 +417,13 @@ def convert(md):
|
|||
# Spend at most 5 seconds rendering.
|
||||
# Sometimes Python-Markdown is really slow; see
|
||||
# https://trac.humbughq.com/ticket/345
|
||||
html = timeout(5, _md_engine.convert, md)
|
||||
return timeout(5, _md_engine.convert, md)
|
||||
except:
|
||||
from zephyr.models import Recipient
|
||||
from zephyr.lib.actions import internal_send_message
|
||||
|
||||
cleaned = _sanitize_for_log(md)
|
||||
|
||||
html = '<p>[Humbug note: Sorry, we could not understand the formatting of your message]</p>'
|
||||
|
||||
# Output error to log as well as sending a humbug and email
|
||||
logging.getLogger('').error('Exception in Markdown parser: %sInput (sanitized) was: %s'
|
||||
% (traceback.format_exc(), cleaned))
|
||||
|
@ -436,5 +434,4 @@ def convert(md):
|
|||
mail.mail_admins(subject, "Failed message: %s\n\n%s\n\n" % (
|
||||
cleaned, traceback.format_exc()),
|
||||
fail_silently=False)
|
||||
|
||||
return html
|
||||
return None
|
||||
|
|
|
@ -225,7 +225,10 @@ class Message(models.Model):
|
|||
client = self.sending_client.name)
|
||||
|
||||
if apply_markdown:
|
||||
obj['content'] = bugdown.convert(self.content)
|
||||
rendered_content = bugdown.convert_safe(self.content)
|
||||
if rendered_content is None:
|
||||
rendered_content = '<p>[Humbug note: Sorry, we could not understand the formatting of your message]</p>'
|
||||
obj['content'] = rendered_content
|
||||
obj['content_type'] = 'text/html'
|
||||
else:
|
||||
obj['content'] = self.content
|
||||
|
|
Loading…
Reference in New Issue