mirror of https://github.com/zulip/zulip.git
markdown: Increase max rendered message length to 1MB.
This should help with #17425, where messages with lots of LaTeX are lost, due to the large expansion factor. This isn't a total fix for this - large messages with lots of LaTeX can still end up larger than 1MB, and rendering could timeout, but this fix should help significantly. 1MB is still small enough that I don't expect we'll run into any DOS problems - my testing didn't show any problems rendering messages that contain ~1MB of LaTeX.
This commit is contained in:
parent
b584790541
commit
d5ba94082a
|
@ -2612,9 +2612,9 @@ def do_convert(
|
|||
# rest of the codebase from any bugs where we end up rendering
|
||||
# something huge.
|
||||
MAX_MESSAGE_LENGTH = settings.MAX_MESSAGE_LENGTH
|
||||
if len(rendered_content) > MAX_MESSAGE_LENGTH * 10:
|
||||
if len(rendered_content) > MAX_MESSAGE_LENGTH * 100:
|
||||
raise MarkdownRenderingException(
|
||||
f"Rendered content exceeds {MAX_MESSAGE_LENGTH * 10} characters (message {logging_message_id})"
|
||||
f"Rendered content exceeds {MAX_MESSAGE_LENGTH * 100} characters (message {logging_message_id})"
|
||||
)
|
||||
return rendered_content
|
||||
except Exception:
|
||||
|
|
|
@ -2749,9 +2749,9 @@ class MarkdownErrorTests(ZulipTestCase):
|
|||
|
||||
@override_settings(MAX_MESSAGE_LENGTH=10)
|
||||
def test_ultra_long_rendering(self) -> None:
|
||||
"""A rendered message with an ultra-long length (> 10 * MAX_MESSAGE_LENGTH)
|
||||
"""A rendered message with an ultra-long length (> 100 * MAX_MESSAGE_LENGTH)
|
||||
throws an exception"""
|
||||
msg = "mock rendered message\n" * settings.MAX_MESSAGE_LENGTH
|
||||
msg = "mock rendered message\n" * 10 * settings.MAX_MESSAGE_LENGTH
|
||||
|
||||
with mock.patch("zerver.lib.markdown.timeout", return_value=msg), mock.patch(
|
||||
"zerver.lib.markdown.markdown_logger"
|
||||
|
|
Loading…
Reference in New Issue