Check that message subject and content are nonempty on edit.

Fixes: Trac #1455, #1448
See also: Trac #213

(imported from commit 0d839da13ac22e1648b0d2a7cf09d1c1218b98ae)
This commit is contained in:
Kevin Mehall
2013-07-11 14:53:30 -04:00
parent 86151bb5ef
commit 77aeee118b

View File

@@ -941,6 +941,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 content == "":
raise JsonableError("Message can't be empty")
if len(content) > MAX_MESSAGE_LENGTH:
raise JsonableError("Message too long")
rendered_content = message.render_markdown(content)
@@ -962,6 +964,10 @@ def do_update_message(user_profile, message_id, subject, content):
event["rendered_content"] = rendered_content
if subject is not None:
subject = subject.strip()
if subject == "":
raise JsonableError("Subject can't be empty")
if len(subject) > MAX_SUBJECT_LENGTH:
raise JsonableError("Subject too long")
event["orig_subject"] = message.subject