Fix regression in whitespace stripping at the start of messages.

This fixes a regression in 4060a97656,
which incorrectly stripped whitespace at the start of messages as
well.

Fixes #3719.
This commit is contained in:
Tim Abbott 2017-02-18 14:47:18 -08:00
parent d75a1b0bfc
commit 6ba1cd797b
2 changed files with 3 additions and 3 deletions

View File

@ -1249,7 +1249,7 @@ def check_message(sender, client, message_type_name, message_to,
message_to = [sender.default_sending_stream.name]
if len(message_to) == 0:
raise JsonableError(_("Message must have recipients"))
message_content = message_content_raw.strip()
message_content = message_content_raw.rstrip()
if len(message_content) == 0:
raise JsonableError(_("Message must not be empty"))
message_content = truncate_body(message_content)

View File

@ -861,11 +861,11 @@ class MessagePOSTTest(ZulipTestCase):
"""
self.login("hamlet@zulip.com")
post_data = {"type": "stream", "to": "Verona", "client": "test suite",
"content": "I like whitespace at the end! \n\n \n", "subject": "Test subject"}
"content": " I like whitespace at the end! \n\n \n", "subject": "Test subject"}
result = self.client_post("/json/messages", post_data)
self.assert_json_success(result)
sent_message = self.get_last_message()
self.assertEqual(sent_message.content, "I like whitespace at the end!")
self.assertEqual(sent_message.content, " I like whitespace at the end!")
def test_long_message(self):
# type: () -> None