zulip/zerver
Lauryn Menard 06dd6f8254 message-send: Deduplicate check of `settings.MAX_MESSAGE_LENGTH`.
Removes the initial check in `_internal_prep_message` of the length
of the message content because the `check_message` in the try block
will call `normalize_body` on the message content string, which
does a more robust check of the message content (empty string, null
bytes, length). If the message content length exceeds the value of
`settings.MAX_MESSAGE_LENGTH`, then it is truncated based on that
value. Updates associated backend test for these changes.

The removed length check would truncate the message content with a
hard coded value instead of using the value for
`settings.MAX_MESSAGE_LENGTH`.

Also, removes an extraneous comment about removing null bytes. If
there are null bytes in the message content, then `normalize_body`
will raise an error.

Note that the previous check had intentionally reduced any message over
the 10000 character limit to 3900 characters, with the code in
question dating to 2012's 100df7e349.

The 3900 character truncating rule was implemented for incoming emails
with the email gateway, and predated other features to help with
overly long messages (better stripping of email footers via Talon,
introduced in f1f48f305e, and
condensing, introduced in c92d664b44).
While we could preserve that logic if desired, it likely is no longer
a necessary or useful variation from our usual truncation rules.
2023-02-20 12:55:15 -08:00
..
actions message-send: Deduplicate check of `settings.MAX_MESSAGE_LENGTH`. 2023-02-20 12:55:15 -08:00
data_import black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
integration_fixtures/nagios
lib rabbitmq: Add a RABBITMQ_PORT setting. 2023-02-20 12:04:25 -08:00
management ruff: Fix PIE810 Call `startswith` once with a `tuple`. 2023-02-08 16:40:35 -08:00
migrations settings: Remove realm-level email_address_visibility setting. 2023-02-10 17:40:33 -08:00
openapi api-docs: Update content parameter for `max_message_length`. 2023-02-20 12:03:12 -08:00
tests message-send: Deduplicate check of `settings.MAX_MESSAGE_LENGTH`. 2023-02-20 12:55:15 -08:00
tornado black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
views settings: Remove realm-level email_address_visibility setting. 2023-02-10 17:40:33 -08:00
webhooks ruff: Fix PIE810 Call `startswith` once with a `tuple`. 2023-02-08 16:40:35 -08:00
worker deferred_work: Log at start of the work. 2023-02-09 12:06:38 -08:00
__init__.py
apps.py sentry: Initialize sentry in AppConfig ready hook. 2022-09-26 12:42:36 -07:00
context_processors.py ruff: Fix RSE102 Unnecessary parentheses on raised exception. 2023-02-04 16:34:55 -08:00
decorator.py ruff: Fix RSE102 Unnecessary parentheses on raised exception. 2023-02-04 16:34:55 -08:00
filters.py
forms.py ruff: Fix SIM105 Use `contextlib.suppress` instead of try-except-pass. 2023-01-23 11:18:36 -08:00
logging_handlers.py python: Use Python 3.8 typing.{Protocol,TypedDict}. 2022-04-27 12:57:49 -07:00
middleware.py ruff: Fix PIE810 Call `startswith` once with a `tuple`. 2023-02-08 16:40:35 -08:00
models.py model: Handle parsed user-agents longer than 30 characters. 2023-02-14 14:58:15 -08:00
signals.py requirements: Upgrade to Django 4.0. 2022-07-13 16:07:17 -07:00