Commit Graph

13470 Commits

Author SHA1 Message Date
nessita 17fa7592af [5.1.x] Fixed #35809 -- Set background color for selected rows in the admin's form select widget.
Regression in b47bdb4cd9.

Thank you Giannis Terzopoulos for the review, and Tom Carrick and Sarah Boyce
for the review.

Backport of 679d57816d from main.
2024-10-08 10:02:33 -03:00
Gastón Avila 590f5e09f0 [5.1.x] Fixed #35732 -- Wrapped ConcatPair expression in parentheses to ensure operator precedence.
When ConcatPair was updated to use || this lost the implicit wrapping from CONCAT(...).
This broke the WHERE clauses when used in combination with PostgreSQL trigram similarity.

Regression in 6364b6ee10.

Backport of c3ca6075cc from main.

Co-authored-by: Emiliano Cuenca <106986074+emicuencac@users.noreply.github.com>
2024-09-11 14:40:48 +02:00
Wassef Ben Ahmed 33cd593420 [5.1.x] Fixed #32831 -– Allowed cache tests to be retried via a new "retry" decorator.
Backport of 957c54d945 from main.
2024-09-05 18:26:03 -03:00
Natalia 3c733c78d6 [5.1.x] Fixed CVE-2024-45231 -- Avoided server error on password reset when email sending fails.
On successful submission of a password reset request, an email is sent
to the accounts known to the system. If sending this email fails (due to
email backend misconfiguration, service provider outage, network issues,
etc.), an attacker might exploit this by detecting which password reset
requests succeed and which ones generate a 500 error response.

Thanks to Thibaut Spriet for the report, and to Mariusz Felisiak, Adam
Johnson, and Sarah Boyce for the reviews.
2024-09-03 09:24:21 -03:00
Sarah Boyce 022ab0a75c [5.1.x] Fixed CVE-2024-45230 -- Mitigated potential DoS in urlize and urlizetrunc template filters.
Thanks MProgrammer (https://hackerone.com/mprogrammer) for the report.
2024-09-03 09:24:13 -03:00
Sarah Boyce 6203965960 [5.1.x] Fixed #35716 -- Fixed VariableDoesNotExist when rendering admin fieldsets.
Regression in 01ed59f753.

Thank you to Fábio Domingues and Marijke Luttekes for the report,
and thank you to Natalia Bidart for the review.

Backport of fd1dd76778 from main.
2024-08-30 20:52:41 +02:00
Sarah Boyce 26c06671d9 [5.1.x] Fixed #35688 -- Restored timezone and role setters to be PostgreSQL DatabaseWrapper methods.
Following the addition of PostgreSQL connection pool support in
Refs #33497, the methods for configuring the database role and timezone
were moved to module-level functions. This change prevented subclasses
of DatabaseWrapper from overriding these methods as needed, for example,
when creating wrappers for other PostgreSQL-based backends.

Thank you Christian Hardenberg for the report and to
Florian Apolloner and Natalia Bidart for the review.

Regression in fad334e1a9.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>

Backport of 7380ac5734 from main.
2024-08-28 19:25:55 -03:00
Simon Charette 9a461cae3e [5.1.x] Fixed #35666 -- Documented stacklevel usage and testing, and adjusted test suite accordingly.
Over the years we've had multiple instances of hit and misses when
emitting warnings: either setting the wrong stacklevel or not setting
it at all.

This work adds assertions for the existing warnings that were declaring
the correct stacklevel, but were lacking tests for it.

Backport of 57307bbc7d from main.
2024-08-28 11:47:15 -03:00
Simon Charette dd58edcc37 [5.1.x] Refs #35405 -- Adjusted deprecation warning stacklevel in FieldCacheMixin.get_cache_name().
Backport of 39abd56a7f from main.
2024-08-28 11:46:49 -03:00
Simon Charette 8f5d2c374a [5.1.x] Refs #35326 -- Adjusted deprecation warning stacklevel in FileSystemStorage.OS_OPEN_FLAGS.
Backport of 47f18a7226 from main.
2024-08-28 11:46:23 -03:00
Simon Charette c87007ab60 [5.1.x] Refs #35060 -- Adjusted deprecation warning stacklevel in Model.save()/asave().
Backport of 52ed2b645e from main.
2024-08-28 11:45:35 -03:00
Mariusz Felisiak e435b44be6 [5.1.x] Refs #34900 -- Updated requirements for Python 3.13.
Backport of 07a4d23283 from main.
2024-08-28 10:10:05 -03:00
Adam Johnson 03e0ab5c64 [5.1.x] Refs #34609 -- Fixed deprecation warning stack level in format_html().
Co-authored-by: Simon Charette <charette.s@gmail.com>

Backport of 2b71b2c8dc from main.
2024-08-27 15:17:47 -03:00
Sarah Boyce c9a8d005ee [5.1.x] Improved test coverage of urlize.
Backport of c6d1f98d26 from main.
2024-08-26 13:16:05 -03:00
Natalia da22e6cb3c [5.1.x] Fixed #35678 -- Removed "usable_password" field from BaseUserCreationForm.
Refs #34429: Following the implementation allowing the setting of
unusable passwords via the admin site, the `BaseUserCreationForm` and
`UserCreationForm` were extended to include a new field for choosing
whether password-based authentication for the new user should be enabled
or disabled at creation time.
Given that these forms are designed to be extended when implementing
custom user models, this branch ensures that this new field is moved to
a new, admin-dedicated, user creation form `AdminUserCreationForm`.

Regression in e626716c28.

Thanks Simon Willison for the report, Fabian Braun and Sarah Boyce for
the review.

Backport of 0ebed5fa95 from main.
2024-08-19 12:41:23 -03:00
Natalia cfad0655c2 [5.1.x] Refs #35678 -- Split tests for BaseUserCreationForm when using a custom User model.
This work also allows to subclass BaseUserCreationFormTest to reuse the
tests and assertions for testing forms that extend BaseUserCreationForm,
which is now used for UserCreationFormTest, increasing its coverage.

Backport of b60fd8722f from main.
2024-08-19 12:40:57 -03:00
Simon Charette df236b0bcb [5.1.x] Fixed #35665 -- Fixed a crash when passing an empty order_by to Window.
This also caused un-ordered sliced prefetches to crash as they rely on Window.

Regression in e16d0c176e that made OrderByList
piggy-back ExpressionList without porting the empty handling that the latter
provided.

Supporting explicit empty ordering on Window functions and slicing is arguably
a foot-gun design due to how backends will return undeterministic results but
this is a problem that requires a larger discussion.

Refs #35064.

Thanks Andrew Backer for the report and Mariusz for the review.

Backport of 602fe961e6 from main.
2024-08-13 11:28:03 +02:00
Mariusz Felisiak d9aeb23edb [5.1.x] Fixed #35661 -- Fixed test_too_many_digits_to_rander() test crash on PyPy.
Thanks Michał Górny for the report.

Backport of 7fb15ad5bc from main.
2024-08-08 09:55:21 +02:00
Natalia d5ad743e79 [5.1.x] Fixed i18n.tests.TranslationTests.test_plural to use correct French translation. 2024-08-07 09:56:31 -03:00
Simon Charette e2583fbc2e [5.1.x] Fixed CVE-2024-42005 -- Mitigated QuerySet.values() SQL injection attacks against JSON fields.
Thanks Eyal (eyalgabay) for the report.
2024-08-06 08:51:22 +02:00
Mariusz Felisiak bd807c0c25 [5.1.x] Fixed CVE-2024-41991 -- Prevented potential ReDoS in django.utils.html.urlize() and AdminURLFieldWidget.
Thanks Seokchan Yoon for the report.

Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2024-08-06 08:51:22 +02:00
Sarah Boyce 0c1a890916 [5.1.x] Fixed CVE-2024-41990 -- Mitigated potential DoS in urlize and urlizetrunc template filters.
Thanks to MProgrammer for the report.
2024-08-06 08:51:22 +02:00
Sarah Boyce 0504af6429 [5.1.x] Fixed CVE-2024-41989 -- Prevented excessive memory consumption in floatformat.
Thanks Elias Myllymäki for the report.

Co-authored-by: Shai Berger <shai@platonix.com>
2024-08-06 08:51:22 +02:00
Sarah Boyce 2ba4f4b0b5 [5.1.x] Fixed #35657 -- Made FileField handle db_default values.
Backport of 8deb6bb1fc from main.
2024-08-05 16:37:26 -03:00
David Sanders aed4ffe189 [5.1.x] Fixed #35638 -- Updated validate_constraints to consider db_default.
Backport of 509763c799 from main.
2024-08-05 17:36:15 +02:00
John Parton 88ebcb1856 [5.1.x] Fixed #35628 -- Allowed compatible GeneratedFields for ModelAdmin.date_hierarchy.
Backport of 7f8d839722 from main.
2024-08-05 15:28:40 +02:00
Simon Charette 55f5292701 [5.1.x] Fixed #35643 -- Fixed a crash when ordering a QuerySet by a reference containing "__".
Regression in b0ad41198b.

Refs #34013. The initial logic did not consider that annotation aliases
can include lookup or transform separators.

Thanks Gert Van Gool for the report and Mariusz Felisiak for the review.
Backport of a16f13a866 from main.
2024-08-02 16:22:05 -03:00
Tim Graham e9d4b03680 [5.1.x] Added missing skips in constraint tests.
Backport of b6ad8b687a from main.
2024-07-26 17:02:04 +02:00
nessita 694c45118a [5.1.x] Added dedicated test for invalid inputs in floatformat template filter tests.
Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>

Backport of 1b277b45cc from main.
2024-07-25 16:17:56 -03:00
Lorenzo Peña 741f33eaf1 [5.1.x] Fixed #35627 -- Raised a LookupError rather than an unhandled ValueError in get_supported_language_variant().
LocaleMiddleware didn't handle the ValueError raised by
get_supported_language_variant() when language codes were
over 500 characters.

Regression in 9e9792228a.

Backport of 0e94f292cd from main.
2024-07-25 09:40:49 +02:00
Simon Charette d8116bf7f5 [5.1.x] Fixed #35625 -- Fixed a crash when adding a field with db_default and check constraint.
This is the exact same issue as refs #30408 but for creating a model with a
constraint containing % escapes instead of column addition. All of these issues
stem from a lack of SQL and parameters separation from the BaseConstraint DDL
generating methods preventing them from being mixed with other parts of the
schema alteration logic that do make use of parametrization on some backends
(e.g. Postgres, MySQL for DEFAULT).

Prior to the addition of Field.db_default and GeneratedField in 5.0
parametrization of DDL was never exercised on model creation so this is
effectively a bug with db_default as the GeneratedField case was addressed by
refs #35336.

Thanks Julien Chaumont for the report and Mariusz Felisiak for the review.

Backport of f359990e49 from main.
2024-07-25 07:51:45 +02:00
Sarah Boyce e42defb63b [5.1.x] Fixed #35604, Refs #35326 -- Made FileSystemStorage.exists() behaviour independent from allow_overwrite.
Partially reverts 0b33a3abc2.

Storage.exists(name) was documented to "return False if
the name is available for a new file." but return True if
the file exists. This is ambiguous in the overwrite file
case. It will now always return whether the file exists.

Thank you to Natalia Bidart and Josh Schneier for the
review.

Backport of 8d6a20b656 from main.
2024-07-24 14:58:57 +02:00
Mariusz Felisiak e5d2664908 [5.1.x] Updated asgiref dependency for 5.1 release series.
Backport of df35cf578f from main.
2024-07-24 08:25:45 +02:00
Simon Charette 8fb7d30456 [5.1.x] Fixed #35603 -- Prevented F.__contains__() from hanging.
Regression in 94b6f101f7.

Backport of 6b3f55446f from main.
2024-07-18 08:41:55 +02:00
Hisham Mahmood 5eef80b56e [5.1.x] Fixed #35606, Refs #34045 -- Fixed rendering of ModelAdmin.action_checkbox for models with a __html__ method.
Thank you Claude Paroz for the report.

Regression in 85366fbca7.

Backport of 182f262b15 from main.
2024-07-18 08:12:36 +02:00
Simon Charette 4d8e574379 [5.1.x] Fixed #35594 -- Added unique nulls distinct validation for expressions.
Thanks Mark Gensler for the report.

Backport of adc0b6aac3 from main.
2024-07-17 12:56:01 +02:00
Simon Charette a2791f5ea2 [5.1.x] Refs #30581 -- Made unattached UniqueConstraint(fields) validation testable.
The logic allowing UniqueConstraint(fields).validate to preserve backward
compatiblity with Model.unique_error_message failed to account for cases where
the constraint might not be attached to a model which is a common pattern
during testing.

This changes allows for arbitrary UniqueConstraint(fields) to be tested in
isolation without requiring actual models backing them up.

Co-authored-by: Mark G <mark.gensler@protonmail.com>

Backport of 13922580cc from main.
2024-07-17 12:55:36 +02:00
nessita df7ebb8b02 [5.1.x] Refs #10941 -- Renamed test file test_query_string.py to test_querystring.py.
This follows previous renames made in 27043bde5b.

Backport of 5dc17177c3 from main.
2024-07-16 22:17:13 -03:00
Sarah Boyce 91a5b5a4bb [5.1.x] Refs #10941 -- Renamed query_string template tag to querystring.
Backport of 27043bde5b from main.
2024-07-15 13:29:54 -03:00
Mariusz Felisiak ebcbf73153 [5.1.x] Refs #35560 -- Corrected required feature flags in GeneratedModelUniqueConstraint.
Backport of 2d3bb414cf from main.
2024-07-15 10:22:52 +02:00
Sarah Boyce e99ccc4342 [5.1.x] Fixed CVE-2024-39614 -- Mitigated potential DoS in get_supported_language_variant().
Language codes are now parsed with a maximum length limit of 500 chars.

Thanks to MProgrammer for the report.
2024-07-09 09:42:58 -03:00
Natalia 6d36203648 [5.1.x] Fixed CVE-2024-39330 -- Added extra file name validation in Storage's save method.
Thanks to Josh Schneier for the report, and to Carlton Gibson and Sarah
Boyce for the reviews.
2024-07-09 09:42:45 -03:00
Michael Manfre f5d16483f3 [5.1.x] Fixed CVE-2024-39329 -- Standarized timing of verify_password() when checking unusuable passwords.
Refs #20760.

Thanks Michael Manfre for the fix and to Adam Johnson for the review.
2024-07-09 09:42:29 -03:00
Adam Johnson 44aef996c8 [5.1.x] Fixed CVE-2024-38875 -- Mitigated potential DoS in urlize and urlizetrunc template filters.
Thank you to Elias Myllymäki for the report.

Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2024-07-09 09:42:12 -03:00
Mark Gensler 2da007737c [5.1.x] Fixed #35560 -- Made Model.full_clean() ignore GeneratedFields for constraints.
Accessing generated field values on unsaved models caused a crash when
validating CheckConstraints and UniqueConstraints with expressions.

Backport of 1005c2abd1 from main.
2024-07-04 11:47:20 +02:00
nessita 432b069b5f [5.1.x] Fixed #35561 -- Made *args and **kwargs parsing more strict in Model.save()/asave().
Backport of e56a32b89b from main.
2024-06-26 12:14:31 -03:00
Sarah Boyce c99ce49d2e [5.1.x] Fixed #35558 -- Increased inline H3 headers color prominence in admin change page.
Backport of e510bb1ab1 from main.
2024-06-25 14:04:07 -03:00
Adam Johnson 387172918f [5.1.x] Fixed #35554, Refs #35060 -- Corrected deprecated *args parsing in Model.save()/asave().
The transitional logic added to deprecate the usage of *args for
Model.save()/asave() introduced two issues that this branch fixes:
 * Passing extra positional arguments no longer raised TypeError.
 * Passing a positional but empty update_fields would save all fields.

Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>

Backport of 28522c3c8d from main.
2024-06-25 13:14:19 -03:00
Carlton Gibson 38248588f6 [5.1.x] Refs #35059 -- Used asyncio.Event in ASGITest.test_asyncio_cancel_error to enforce specific interleaving.
Sleep call leads to a hard to trace error in CI. Using an Event is
more deterministic, and should be less prone to environment
variations.

Bug in 11393ab131.

Backport of f4a08b6ddf from main.
2024-06-25 11:05:37 -03:00
Sarah Boyce 63178036b3 [5.1.x] Fixed #35545, Refs #32833 -- Fixed ContentTypeManager.get_for_models() crash in CreateModel migrations.
Thank you to Csirmaz Bendegúz for the report and Simon Charettes for the review.

Backport of f1705c8780 from main.
2024-06-24 10:21:54 +02:00