zulip/zerver/views
Zixuan James Li 268f858f39 linkifier: Support URL templates for linkifiers.
This swaps out url_format_string from all of our APIs and replaces it
with url_template. Note that the documentation changes in the following
commits  will be squashed with this commit.

We change the "url_format" key to "url_template" for the
realm_linkifiers events in event_schema, along with updating
LinkifierDict. "url_template" is the name chosen to normalize
mixed usages of "url_format_string" and "url_format" throughout
the backend.

The markdown processor is updated to stop handling the format string
interpolation and delegate the task template expansion to the uri_template
library instead.

This change affects many test cases. We mostly just replace "%(name)s"
with "{name}", "url_format_string" with "url_template" to make sure that
they still pass. There are some test cases dedicated for testing "%"
escaping, which aren't relevant anymore and are subject to removal.
But for now we keep most of them as-is, and make sure that "%" is always
escaped since we do not use it for variable substitution any more.

Since url_format_string is not populated anymore, a migration is created
to remove this field entirely, and make url_template non-nullable since
we will always populate it. Note that it is possible to have
url_template being null after migration 0422 and before 0424, but
in practice, url_template will not be None after backfilling and the
backend now is always setting url_template.

With the removal of url_format_string, RealmFilter model will now be cleaned
with URL template checks, and the old checks for escapes are removed.

We also modified RealmFilter.clean to skip the validation when the
url_template is invalid. This avoids raising mulitple ValidationError's
when calling full_clean on a linkifier. But we might eventually want to
have a more centric approach to data validation instead of having
the same validation in both the clean method and the validator.

Fixes #23124.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-04-19 12:20:49 -07:00
..
development emails: Inline CSS in emails in build_email. 2023-04-05 12:22:29 -07:00
__init__.py
alert_words.py actions: Split out zerver.actions.alert_words. 2022-04-14 17:14:31 -07:00
attachments.py actions: Split out zerver.actions.uploads. 2022-04-14 17:14:32 -07:00
auth.py backend-auth: Add user ID to fetch api key responses. 2023-04-04 10:54:49 -07:00
compatibility.py django: Use HttpRequest.headers. 2022-05-13 20:42:20 -07:00
custom_profile_fields.py black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
digest.py mypy: Fix most AnonymousUser type errors. 2021-07-24 14:55:46 -07:00
documentation.py api-docs: Move markdown files to top level directory. 2023-02-02 17:25:40 -08:00
drafts.py backend: Add request as parameter to json_success. 2022-02-04 15:16:56 -08:00
email_mirror.py backend: Add request as parameter to json_success. 2022-02-04 15:16:56 -08:00
events_register.py linkifier: Support URL templates for linkifiers. 2023-04-19 12:20:49 -07:00
home.py black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
hotspots.py actions: Split out zerver.actions.hotspots. 2022-04-14 17:14:31 -07:00
invite.py ruff: Fix RSE102 Unnecessary parentheses on raised exception. 2023-02-04 16:34:55 -08:00
message_edit.py black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
message_fetch.py settings: Add backend code for using user email_address_visibility setting. 2023-02-10 17:35:49 -08:00
message_flags.py black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
message_send.py message-type: Add support for "direct" as value for type parameter. 2023-04-18 12:29:33 -07:00
muted_users.py mute user: Remove unnecessary check for double muting. 2023-02-20 21:04:13 -08:00
presence.py black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
push_notifications.py backend: Add request as parameter to json_success. 2022-02-04 15:16:56 -08:00
reactions.py actions: Split out zerver.actions.reactions. 2022-04-14 17:14:35 -07:00
read_receipts.py read_receipts: Exclude muted users from read receipts. 2022-09-16 16:19:54 -07:00
realm.py user_settings: Add web_mark_read_on_scroll_policy field. 2023-04-18 18:32:02 -07:00
realm_domains.py realm_domains: Allow only owners to add, edit or delete domains. 2022-09-16 15:27:52 -07:00
realm_emoji.py black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
realm_export.py realm_export: Add transaction.atomic to export_realm. 2023-01-26 10:49:19 -08:00
realm_icon.py black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
realm_linkifiers.py linkifier: Support URL templates for linkifiers. 2023-04-19 12:20:49 -07:00
realm_logo.py upload: Add assertions before accessing uploaded files. 2022-06-23 22:09:05 -07:00
realm_playgrounds.py actions: Split out zerver.actions.realm_playgrounds. 2022-04-14 17:14:30 -07:00
registration.py registration: Use get_realm_create_form_context for register.html. 2023-03-27 15:44:42 -07:00
report.py report_error: Remove API endpoint for client error reporting. 2023-04-13 14:59:58 -07:00
scheduled_messages.py scheduled_messages: Add endpoints to fetch and delete them. 2023-04-14 17:38:37 -07:00
sentry.py sentry: Provide a server-side tunnel. 2023-03-24 15:16:38 -07:00
storage.py backend: Add request as parameter to json_success. 2022-02-04 15:16:56 -08:00
streams.py user_groups: Add allow_nobody_group to access_user_group_for_setting. 2023-04-11 09:02:09 -07:00
submessage.py actions: Split out zerver.actions.submessage. 2022-04-14 17:14:30 -07:00
thumbnail.py docs: Remove some outdated references to thumbnailing.md doc. 2022-07-12 17:44:24 -07:00
tutorial.py backend: Add request as parameter to json_success. 2022-02-04 15:16:56 -08:00
typing.py message-type: Add support for "direct" as value for type parameter. 2023-04-18 12:29:33 -07:00
unsubscribe.py black: Reformat with Black 23. 2023-02-02 10:40:13 -08:00
upload.py upload: Rename upload_message_image_from_request. 2023-03-02 16:36:19 -08:00
user_groups.py user_groups: Send a message on changing user-groups subscribers. 2023-04-06 19:03:26 -07:00
user_settings.py user_settings: Add web_mark_read_on_scroll_policy field. 2023-04-18 18:32:02 -07:00
user_topics.py user_topics: Add a new endpoint to update visibility_policy. 2023-04-03 22:31:49 -07:00
users.py settings: Add backend code for using user email_address_visibility setting. 2023-02-10 17:35:49 -08:00
video_calls.py actions: Split out zerver.actions.video_calls. 2022-04-14 17:14:30 -07:00
zephyr.py ruff: Fix PLW0602 Using global but no assignment is done. 2023-01-04 16:25:07 -08:00