Commit Graph

20480 Commits

Author SHA1 Message Date
Aditya Kumar Kasaudhan
fe99ed9993 navigation_view: Add reminders to built-in view fragments.
This omission had no effect on current users, but will be important once view 
customization is implemented.

It was missed in zulip#32528.
2025-10-19 17:39:13 -07:00
Alex Vandiver
1e943ae7df python: Elide type=str from argparse arguments. 2025-10-17 15:34:34 -07:00
Alex Vandiver
9815db9811 upload: Use normpath when comparing to LOCAL_UPLOADS_DIR.
This prevents a development-mode-only directory traversal attack,
where the Django development server could be made to respond to
requests for `/user_avatars/../../../../../../etc/passwd`.

The production server is not affected by this vulnerability, as
nginx's configuration sets `PATH_INFO` to `$document_uri`, which is
normalized[^1] -- that is, by the time uwsgi and Django see it, the path
has been percent-decoded once, and all `../` path components have been
applied[^2].

Close this by explicitly normalizing the paths before comparing; the
`LOCAL_UPLOADS_DIR` side is unlikely to require normalization as well,
but is also normalized for consistency.  The failure here is left as
an assertion failure, and not a JsonableError, because it only affects
the development server.

[^1]: https://nginx.org/en/docs/http/ngx_http_core_module.html#var_uri
[^2]: https://nginx.org/en/docs/http/ngx_http_core_module.html#location
2025-10-14 12:56:10 -07:00
Lauryn Menard
c2d008aadb test-signup: Confirm all invalid email field error messages.
In Django, when cleaning a form field, all validators are run on
the field and all validation error messages are all collected.
Updates our test for invalid email addresses when creating a new
realm to confirm all expected error messages from the various
validators that are run on that field.
2025-10-14 12:19:07 -07:00
Lauryn Menard
f55c89a87f forms: Call superclass clean method for CaptchaRealmCreationForm.
Ensures that the form fields set in the superclass are validated.
2025-10-14 12:19:07 -07:00
Lauryn Menard
7185f2c236 forms: Set realm_creation field one time when initializing form.
In commit c7a08f3b77, we started setting the realm_creation field
in both the RegistrationForm and its superclass, RealmDetailsForm,
which was likely a copy and paste error.

Since we only need to set the realm_creation field once when
initializing the form fields, we set it in the RealmDetailsForm,
which also removes any confusion related to the comment about
removing extra kwargs in the RegistrationForm initialization.
2025-10-14 12:19:07 -07:00
Niloth P
ad122af6f8 integrations: Use dir_name instead of name for default view fn.
Use the directory name as the template literal in the default view
function path.
2025-10-14 12:17:05 -07:00
Niloth P
23740c97a4 integrations: Remove redundant arguments. 2025-10-14 12:17:05 -07:00
Niloth P
f33ef8f206 integrations: Rename IFTTT view function to match conventions. 2025-10-14 12:17:05 -07:00
Tim Abbott
e4ba536eae migrations: Add merge migration for backport of 0753.
Systems upgrading from 11.x will have 0753 and not 0752, while systems
upgrading from main may have 0752 and not 0753, so a merge migration
is required to smoothly handle upgrades from both states.
2025-10-14 11:56:57 -07:00
Alya Abbott
aac651fa39 updates: Add update message (level=22). 2025-10-13 23:18:00 -07:00
PieterCK
c54dee9fab slack_integration: Audit the Slack bot token scope requirements.
This clarifies which Slack bot token scopes the integration really uses.
Extraneous scopes are: `users:read.email`, `team:read`, and
`emoji:read`.

Fixes part of #30827.
2025-10-10 09:55:38 -07:00
Mateusz Mandera
e65fb2d051 slack: Requote image_url in render_attachment.
Slack attachment urls with white spaces,
e.g. `https://example.com/some file.png`,
were rejected by `check_url`. We want to call `requote_url` to deal with
any url-quoting jankiness that may be present in the exported data.
2025-10-10 09:52:50 -07:00
Mateusz Mandera
d484fd95d8 slack: Add missing block types.
1. `call` is a block type we've observed in the wild in a Slack export,
   despite not being documented in
   https://docs.slack.dev/reference/block-kit/blocks/

2. We already have the logic for converting `condition` block type below
   in the function, but it was erroneously missing from the list of valid
   types.
2025-10-10 09:52:44 -07:00
Mateusz Mandera
a473d05840 slack: Fix formation of bot email addresses with non-ascii chars. 2025-10-10 09:49:35 -07:00
Tom Hubrecht
5ed5fa3315 webhooks_gitea: Use the correct actor for pull_request actions
The user associated to a pull request is always its creator, however,
when closing a pull request, this can be the wrong actor. The paylod
contains the actor in the `sender` value, use this instead.
2025-10-10 09:47:45 -07:00
Shubham Padia
9bb082a315 docs: Add tests for adding canonical URL to relevant doc pages.
Add these tests for /policies, /api and /integrations.
2025-10-10 09:18:13 -07:00
Lauryn Menard
b42d3e77e7 forms: Set EmailField max_length to match Django Model.EmailField.
Django's Model.EmailField's default max_length is 254 characters,
while the Form.EmailField's default max length is 320 characters.
The longer valid length for form email fields raises an error
when an email with over 254 characters is validated and the server
attempts to create a preregistration user or realm.

Sets the max length on current form EmailFields to match the max
length on corresponding email fields in the database.

For the form MultiEmailField used on the find account/team page,
we don't need to set the max length to 254, but we don't expect
any emails longer than that to match any existing user accounts.
Adds tests in `zerver/tests/test_signup.py` for form submissions
with long email addresses.
2025-10-09 15:47:04 -04:00
Alex Vandiver
fdcfafd13d send_custom_email: Add a flag for sending release announcements. 2025-10-09 12:10:15 -07:00
Alex Vandiver
79e718ed3a send_email: Move break into custom_email_sender. 2025-10-09 12:10:15 -07:00
Anders Kaseorg
b8f8056f56 markdown: Use re-exported guess_type to ensure adding EXTRA_MIME_TYPES.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-10-08 23:36:15 -07:00
Anders Kaseorg
b05b5e72f5 test_helpers: Use care in load_subdomain_token URL parsing.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-10-08 23:33:47 -07:00
Alex Vandiver
afd7c4b1d1 register_remote_server: Check for NS records, now just A/AAAA.
We shouldn't declare that the domain doesn't exist, if it has a valid
NS record but no A/AAAA.
2025-10-06 22:20:02 -07:00
Alex Vandiver
a0e5be7f2e register_remote_server: Be more explicit about example.com emails. 2025-10-06 22:20:01 -07:00
Alex Vandiver
fc42c70346 register_remote_server: Explain why we're validating the domain. 2025-10-06 22:20:01 -07:00
Tim Abbott
9361a3cffe test_classes: Give useful error when using /json/ URLs wrong. 2025-10-03 15:49:20 -07:00
Tim Abbott
981fd35288 test_channel_creation: Fix misuse of test helper APIs.
This mix of authentication and endpoints used here was incoherent, and
throws an exception following the next commit.
2025-10-03 15:49:20 -07:00
Niloth P
1f4267f3e0 integrations: Add screenshot configs for monitoring integrations.
that do not have fixtures.
2025-10-03 15:38:03 -07:00
Niloth P
d70b099644 integrations: Add screenshot configs for productivity integrations.
that do not have fixtures.
2025-10-03 15:38:03 -07:00
Niloth P
433f43a9b4 integrations: Add screenshot configs for communication integrations.
that do not have fixtures.
2025-10-03 15:38:03 -07:00
Niloth P
f5e925b26b integrations: Add screenshot configs for the project management type.
of integrations that do not have fixtures.
2025-10-03 15:38:03 -07:00
Niloth P
24eab61ab0 integrations: Add screenshot configs for deployment integrations.
that do not have fixtures.
2025-10-03 15:38:03 -07:00
Niloth P
7f2161bffa integrations: Add screenshot configs for fixtureless CI integrations. 2025-10-03 15:38:03 -07:00
Niloth P
65d01b553b integrations: Add screenshot configs for fixtureless VCS integrations.
Co-authored-by: Lauryn Menard <lauryn@zulip.com>
2025-10-03 15:38:03 -07:00
Niloth P
23a8e26741 integrations: Load optional fields for fixtureless screenshot configs.
The hardcoded content (topic and message) for the screenshot configs are
loaded from `fixtureless_integrations.py`. Add a new
FIXTURELESS_SCREENSHOT_CONFIG_OPTIONAL_FIELDS dict to maintain the
optional fields of fixtureless screenshot configs, and load both into
FIXTURELESS_SCREENSHOT_CONFIG.

This commit does not set any screenshot configs, but only adds the
framework.
2025-10-03 15:38:03 -07:00
Niloth P
c7a6fcaf88 integrations: Add new file for fixtureless screenshot configs registry.
This does not include any screenshot configs, just defining the format,
and loading FIXTURELESS_SCREENSHOT_CONFIG from the file.

Co-authored-by: Lauryn Menard <lauryn@zulip.com>
2025-10-03 15:38:03 -07:00
Anders Kaseorg
890ccec8d4 timestamp: Use localized formatting in format_datetime_to_string.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-10-03 10:43:16 -07:00
Anders Kaseorg
9ca788cbbc update_subscriber_counts: Fix annotate usage.
Commit 7f3bb4523c (#36160) broke this.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-10-03 00:01:44 -07:00
Anders Kaseorg
b742ab18f9 emoji: Remove setting for deprecated Google blobs emoji set.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-10-01 13:35:06 -07:00
Aman Agrawal
024559e1b9 email_notifications: Convert datetime to local date string. 2025-10-01 11:25:00 -07:00
Aman Agrawal
a694fe1865 signals: Extract function to convert datetime to readable string. 2025-10-01 11:25:00 -07:00
Alex Vandiver
755cb7d854 export: Move all queries, when possible, to iterators.
This reduces overall memory usage for large exports.
2025-10-01 11:21:34 -07:00
Alex Vandiver
0ffc0e810c export_search: Switch to using orjson_stream. 2025-10-01 11:21:34 -07:00
Alex Vandiver
67743d150a export: Support streaming iterators when writing JSON. 2025-10-01 11:21:34 -07:00
Alex Vandiver
78bc17ecbe export: Switch chunked() to the itertools.batched definition.
We only require Python 3.10, so we cannot use `itertools.batched`
directly, which came in 3.12.  Include and use a short version of it.
2025-10-01 11:21:34 -07:00
Alex Vandiver
cf33119348 export: Remove export-most-recent symlink.
The only callsite of do_export_realm calls `rmtree` on the output
path, which means this symlink is always dangling.  Since realms can
also be exported by end-users, following it would always be a race
condition, anyways.

Remove it.
2025-10-01 11:21:34 -07:00
Alex Vandiver
6a8deb7115 export: We expect that zerver_client is written late.
This silences a misleading warning; the behaviour changed in
f2024ad625.
2025-10-01 11:21:34 -07:00
Alex Vandiver
d17851a3ed openapi: Remove a debugging statement. 2025-10-01 11:21:34 -07:00
Alex Vandiver
bea7d6ff93 cache_helpers: Use iterators, so we do not keep the full list in memory. 2025-10-01 10:36:37 -07:00
Lauryn Menard
6fb19fdd2d templates: Add rel-canonical link to some documentation pages.
Updates templates/zerver/meta_tags.html to add a rel-canonical
link if REL_CANONICAL_LINK is in the template context dict.

We add REL_CANONICAL_LINK to the documentation context for the
API and integrations documentation pages in all cases. The link
will be self-referencing for the main zulip.com site.

For policies documentation pages, we add REL_CANONICAL_LINK to
the context only when settings.CORPORATE_ENABLED is true, so
that self-hosted servers' policies documentation do not have a
rel-canonical link set.

Part of #35110.
2025-10-01 11:50:59 -04:00