diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index 022d36a643..df48fa5941 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -1970,8 +1970,9 @@ def do_convert(content: Text, # Throw an exception if the content is huge; this protects the # rest of the codebase from any bugs where we end up rendering # something huge. - if len(rendered_content) > MAX_MESSAGE_LENGTH * 2: - raise BugdownRenderingException() + if len(rendered_content) > MAX_MESSAGE_LENGTH * 10: + raise BugdownRenderingException('Rendered content exceeds %s characters' % + (MAX_MESSAGE_LENGTH * 10,)) return rendered_content except Exception: cleaned = privacy_clean_markdown(content) diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py index 9e055f7773..68c46b836a 100644 --- a/zerver/tests/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -1261,7 +1261,7 @@ class BugdownErrorTests(ZulipTestCase): def test_ultra_long_rendering(self) -> None: """A message with an ultra-long rendering throws an exception""" - msg = u'* a\n' * (MAX_MESSAGE_LENGTH // 5) # Rendering is >20K characters + msg = u'* a\n' * MAX_MESSAGE_LENGTH # Rendering is >100K characters with self.simulated_markdown_failure(): with self.assertRaises(bugdown.BugdownRenderingException):