mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
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:
@@ -941,6 +941,8 @@ def do_update_message(user_profile, message_id, subject, content):
|
|||||||
first_rendered_content = old_edit_history_event['prev_rendered_content']
|
first_rendered_content = old_edit_history_event['prev_rendered_content']
|
||||||
|
|
||||||
if content is not None:
|
if content is not None:
|
||||||
|
if content == "":
|
||||||
|
raise JsonableError("Message can't be empty")
|
||||||
if len(content) > MAX_MESSAGE_LENGTH:
|
if len(content) > MAX_MESSAGE_LENGTH:
|
||||||
raise JsonableError("Message too long")
|
raise JsonableError("Message too long")
|
||||||
rendered_content = message.render_markdown(content)
|
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
|
event["rendered_content"] = rendered_content
|
||||||
|
|
||||||
if subject is not None:
|
if subject is not None:
|
||||||
|
subject = subject.strip()
|
||||||
|
if subject == "":
|
||||||
|
raise JsonableError("Subject can't be empty")
|
||||||
|
|
||||||
if len(subject) > MAX_SUBJECT_LENGTH:
|
if len(subject) > MAX_SUBJECT_LENGTH:
|
||||||
raise JsonableError("Subject too long")
|
raise JsonableError("Subject too long")
|
||||||
event["orig_subject"] = message.subject
|
event["orig_subject"] = message.subject
|
||||||
|
|||||||
Reference in New Issue
Block a user