From edc4f51b00daf6d9b17eed954a19b05bdba7530b Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 24 Jun 2013 10:29:30 -0400 Subject: [PATCH] do_update_message: Check max message and subject lengths. (imported from commit 48e8b21c7ca122afc40fcd1482d26185f50cadab) --- zephyr/lib/actions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zephyr/lib/actions.py b/zephyr/lib/actions.py index b1aa7abef5..715543b8f1 100644 --- a/zephyr/lib/actions.py +++ b/zephyr/lib/actions.py @@ -965,6 +965,8 @@ def do_update_message(user_profile, message_id, subject, content): first_rendered_content = old_edit_history_event['prev_rendered_content'] if content is not None: + if len(content) > MAX_MESSAGE_LENGTH: + raise JsonableError("Message too long") rendered_content = bugdown.convert(content, message.sender.realm.domain) if rendered_content is None: raise JsonableError("We were unable to render your updated message") @@ -985,6 +987,8 @@ def do_update_message(user_profile, message_id, subject, content): event["rendered_content"] = rendered_content if subject is not None: + if len(subject) > MAX_SUBJECT_LENGTH: + raise JsonableError("Subject too long") event["orig_subject"] = message.subject message.subject = subject event["subject"] = subject