1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00
Commit Graph

13845 Commits

Author SHA1 Message Date
Jacob Walls
ac9fcf6eb2 [5.2.x] Refs CVE-2025-64459 -- Avoided propagating invalid arguments to Q on dictionary expansion.
Backport of 3c3f463577 from main.
2025-11-05 09:33:29 -03:00
Jacob Walls
6703f364d7 [5.2.x] Fixed CVE-2025-64459 -- Prevented SQL injections in Q/QuerySet via the _connector kwarg.
Thanks cyberstan for the report, Sarah Boyce, Adam Johnson, Simon
Charette, and Jake Howard for the reviews.

Backport of c880530ddd from main.
2025-11-05 09:33:15 -03:00
Jacob Walls
4f5d904b63 [5.2.x] Fixed CVE-2025-64458 -- Mitigated potential DoS in HttpResponseRedirect/HttpResponsePermanentRedirect on Windows.
Thanks Seokchan Yoon for the report, Markus Holtermann for the
triage, and Jake Howard for the review.

Follow-up to CVE-2025-27556 and 39e2297210.

Backport of c880530ddd from main.
2025-11-05 09:32:59 -03:00
Hal Blackburn
cbdf128cb3 [5.2.x] Fixed #36704 -- Fixed system check error for proxy model with a composite pk.
Proxy models subclassing a model with a CompositePrimaryKey were
incorrectly reporting check errors because the check that requires only
local fields to be used in a composite pk was evaluated against the proxy
subclass, which has no fields.

To fix this, composite pk field checks are not evaluated against
proxy subclasses, as none of the checks are applicable to proxy
subclasses. This also has the benefit of not double-reporting real check
errors from an invalid superclass pk.

Thanks Clifford Gama for the review.

Backport of 74564946c3 from main.
2025-11-04 12:00:58 -05:00
Patrick Rauscher
6775888470 [5.2.x] Fixed #36696 -- Fixed NameError when inspecting functions with deferred annotations.
In Python 3.14, annotations are deferred by default, so we should not
assume that the names in them have been imported unconditionally.
2025-10-31 08:47:32 -04:00
Mariusz Felisiak
9b37bd5fe7 [5.2.x] Made RemoteTestResultTest.test_pickle_errors_detection() compatible with tblib 3.2+.
tblib 3.2+ makes exception subclasses with __init__() and the default
__reduce__() picklable. This broke the test for
RemoteTestResult._confirm_picklable(), which expects a specific
exception to fail unpickling.

https://github.com/ionelmc/python-tblib/blob/master/CHANGELOG.rst#320-2025-10-21

This fix defines ExceptionThatFailsUnpickling.__reduce__() in a way
that pickle.dumps(obj) succeeds, but pickle.loads(pickle.dumps(obj))
raises TypeError.

Refs #27301. This preserves the intent of the regression test from
52188a5ca6 without skipping it.

Backport of 548209e620 from main.
2025-10-21 23:14:05 -03:00
Mariusz Felisiak
796456d84e [5.2.x] Fixed RelatedGeoModelTest.test_related_union_aggregate() test on Oracle and GEOS 3.12+.
Backport of 344ae16e1e from main
2025-10-20 16:06:20 +02:00
Mariusz Felisiak
a8c9b5b263 [5.2.x] Refs #35844 -- Doc'd Python 3.14 compatibility.
Backport of 56977b466c from main.
2025-10-17 20:05:19 +02:00
Jacob Walls
dc61f20578 [5.2.x] Refs #36648 -- Removed hardcoded pk in CompositePKAggregateTests.
Backport of bee64561a6 from main.
2025-10-15 23:45:45 -04:00
Jacob Walls
8baee531d4 [5.2.x] Fixed #36648, Refs #33772 -- Accounted for composite pks in first()/last() when aggregating.
Backport of 02eed4f378 from main.
2025-10-14 15:50:26 -04:00
Sarah Boyce
ed8fc39d77 [5.2.x] Fixed CVE-2025-59682 -- Fixed potential partial directory-traversal via archive.extract().
Thanks stackered for the report.

Follow up to 05413afa8c.

Backport of 924a0c092e from main.
2025-10-01 08:25:20 -04:00
Mariusz Felisiak
52fbae0a4d [5.2.x] Fixed CVE-2025-59681 -- Protected QuerySet.annotate(), alias(), aggregate(), and extra() against SQL injection in column aliases on MySQL/MariaDB.
Thanks sw0rd1ight for the report.

Follow up to 93cae5cb2f.

Backport of 41b43c74bd from main.
2025-10-01 08:24:18 -04:00
David Smith
5484d1f2b0 [5.2.x] Fixed OGRInspectTest.test_time_field with memory Spatialite database.
Backport of 82b3b84a78 from main.
2025-09-18 09:35:32 -03:00
antoliny0919
d8e9dec1ad [5.2.x] Fixed #36601 -- Fixed color contrast of FilteredSelectMultiple widget chosen labels in TabularInlines.
Regression in a0f50c2a48.

Backport of 1e7728888d from main.
2025-09-17 10:01:37 +02:00
Jake Howard
4c044fcc86 [5.2.x] Fixed CVE-2025-57833 -- Protected FilteredRelation against SQL injection in column aliases.
Thanks Eyal Gabay (EyalSec) for the report.

Backport of 5171171709 from main.
2025-09-03 13:15:55 +02:00
SaJH
ace59cb83b [5.2.x] Fixed #36431 -- Returned tuples for multi-column ForeignObject in values()/values_list().
Thanks Jacob Walls and Simon Charette for tests.

Signed-off-by: SaJH <wogur981208@gmail.com>

Backport of bb7a7701b1 from main
2025-08-29 15:36:09 -04:00
Mariusz Felisiak
9c9ed6fd7a [5.2.x] Refs #35530 -- Corrected deprecation message in auth.alogin().
Follow up to ceecd518b1.

Backport of b3166e1e15 from main.
2025-08-22 16:15:42 +02:00
Natalia
9a720d5c50 [5.2.x] Fixed #36499 -- Adjusted utils_tests.test_html.TestUtilsHtml.test_strip_tags following Python's HTMLParser new behavior.
Python fixed a quadratic complexity processing for HTMLParser in:
https://github.com/python/cpython/commit/6eb6c5db.

Backport of 2980627502 from main.
2025-08-13 17:48:37 -03:00
Natalia
74fafe2715 [5.2.x] Fixed test_utils.tests.HTMLEqualTests.test_parsing_errors following Python's HTMLParser fixed parsing.
Further details about Python changes can be found in:
0243f97cba.

Refs #36499. Thank you Clifford Gama for the thorough review!

Backport of e4515dad7a from main.
2025-08-13 17:48:37 -03:00
Jacob Walls
a4e27c0c6b [5.2.x] Refs #34378, #36143, #36416 -- Fixed isolation of LookupTests.test_in_bulk_preserve_ordering_with_batch_size().
`max_query_params` is a property, so it must be patched on the class.

Backport of a68e8565cd from main.
2025-08-13 15:30:34 -03:00
jkhall81
bdc3f9e350 [5.2.x] Fixed #36530 -- Extended fields.E347 to check for ManyToManyField involving CompositePrimaryKey on either side.
Thanks to Jacob Walls for the report.

Backport of 2013092b69 from main.
2025-08-05 08:46:56 -03:00
Simon Charette
b3bb7230e1 [5.2.x] Fixed #34871, #36518 -- Implemented unresolved lookups expression replacement.
This allows the proper resolving of lookups when performing constraint
validation involving Q and Case objects.

Thanks Andrew Roberts for the report and Sarah for the tests and review.

Backport of 079d31e698 from main.
2025-08-04 09:42:32 +02:00
Simon Charette
e5ccb69bc3 [5.2.x] Fixed #36198 -- Implemented unresolved transform expression replacement.
This allows the proper resolving of F("field__transform") when
performing constraint validation.

Thanks Tom Hall for the report and Sarah for the test.

Prerequisite for #36518.

Backport of fc30355107 from main.
2025-08-04 09:41:29 +02:00
Simon Charette
3031c512f0 [5.2.x] Fixed #36522 -- Added support for filtering composite pks using a tuple of expressions.
Thanks Jacob Walls for the report, and Sarah Boyce and Mariusz Felisiak
for reviews.

Backport of 0a4999b422 from main.
2025-07-28 16:40:08 -03:00
Natalia
a76587531b [5.2.x] Added SimpleTestCase.enterContext() on Python < 3.11.
This reverts commit 47a618d45c and uses
a solution similar to ed4f83782d instead.
2025-07-16 18:11:53 -03:00
Simon Charette
3df1ad57bf [5.2.x] Fixed #36502 -- Restored UNNEST strategy for foreign key bulk inserts on PostgreSQL.
Regression in 764af7a3d6.

Backport of 0fe218842e from main.
2025-07-10 18:36:01 +02:00
Natalia
47a618d45c Fixed AttributeError for enterContext() on Python < 3.11.
On Jenkins with Python 3.10:

Traceback (most recent call last):
  File "[...]/python3.10/tests/composite_pk/test_filter.py", line 559, in setUp
    self.enterContext(feature_patch)
AttributeError: 'CompositePKFilterTupleLookupFallbackTests' object has no attribute 'enterContext'
2025-07-02 10:25:21 -03:00
Simon Charette
a150160c9f [5.2.x] Fixed #36464 -- Fixed "__in" tuple lookup on backends lacking native support.
When native support for tuple lookups is missing in a DB backend, it can
be emulated with an EXISTS clause. This is controlled by the backend
feature flag "supports_tuple_lookups".

The mishandling of subquery right-hand side in `TupleIn` (added to
support `CompositePrimaryKey` in Refs #373) was likely missed because
the only core backend we test with the feature flag disabled
(Oracle < 23.4) supports it natively.

Thanks to Nandana Raol for the report, and to Sarah Boyce, Jacob Walls,
and Natalia Bidart for reviews.

Backport of 192bc7a7be from main.
2025-06-30 20:16:08 -03:00
Clifford Gama
1d89691c74 [5.2.x] Fixed #36453 -- Made When.condition resolve with for_save=False.
Value(None, JSONField()) when used in When.condition incorrectly resolved with
for_save=True, resulting in the value being serialized as SQL NULL instead of
JSON null.

Regression in c1fa3fdd04.

Thanks to Thomas McKay for the report, and to David Sanders and Simon Charettes
for the review.

Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>

Backport of 104cbfd44b from main.
2025-06-16 10:41:24 +02:00
Jake Howard
4de4edf2c0 [5.2.x] Fixed #36447 -- Selected preferred media type based on quality.
When matching which entry in the `Accept` header should be used for
a given media type, the specificity matters. However once those are
resolved, only the quality matters when selecting preference.

Regression in c075508b4d.

Thank you to Anders Kaseorg for the report.

Backport of 12c1557060 from main.
2025-06-16 09:27:46 +02:00
Mariusz Felisiak
aec11dbb4c [5.2.x] Refs #36419 -- Fixed BulkUpdateTests.test_json_field_sql_null() crash on Oracle.
Follow up to c1fa3fdd04.

Backport of f5441e42da from main.
2025-06-10 08:42:37 +02:00
Natalia
cc5079730a [5.2.x] Fixed #36446 -- Restored "q" in internal MediaType.params property.
The "q" key was removed while addressing ticket #36411. Despite
`MediaType.params` is undocumented and considered internal, it was used
in third-party projects (Zulip reported breakage), so this work restored
the `q` key in `params`.

Thanks Anders Kaseorg for the report.

Regression in c075508b4d.

Backport of cf5f36bf90 from main.
2025-06-09 17:39:25 -03:00
Clifford Gama
6fc620b4a8 [5.2.x] Fixed #36419 -- Ensured for_save was propagated when resolving expressions.
The for_save flag wasn't properly propagated when resolving expressions, which
prevented get_db_prep_save() from being called in some cases. This affected
fields like JSONField where None would be saved as JSON null instead of SQL NULL.

Regression in 00c690efbc.

Thanks to David Sanders and Simon Charette for reviews.

Co-authored-by: Adam Johnson <me@adamj.eu>

Backport of c1fa3fdd04 from main.
2025-06-06 17:41:51 +02:00
Jake Howard
8fcc83953c [5.2.x] Refs CVE-2025-48432 -- Prevented log injection in remaining response logging.
Migrated remaining response-related logging to use the `log_response()`
helper to avoid potential log injection, to ensure untrusted values like
request paths are safely escaped.

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

Backport of 9579517552 from main.
2025-06-06 09:07:12 -03:00
Natalia
9d7fc9eb1c [5.2.x] Refs CVE-2025-48432 -- Made SuspiciousOperation logging use log_response() for consistency.
Backport of ff835f439c from main.
2025-06-06 09:07:06 -03:00
Natalia
c042af7147 [5.2.x] Refactored logging_tests to reuse assertions for log records.
Backport of 9d72e7daf7 from main.
2025-06-06 09:06:57 -03:00
Natalia
7456aa23da [5.2.x] Fixed CVE-2025-48432 -- Escaped formatting arguments in log_response().
Suitably crafted requests containing a CRLF sequence in the request
path may have allowed log injection, potentially corrupting log files,
obscuring other attacks, misleading log post-processing tools, or
forging log entries.

To mitigate this, all positional formatting arguments passed to the
logger are now escaped using "unicode_escape" encoding.

Thanks to Seokchan Yoon (https://ch4n3.kr/) for the report.

Co-authored-by: Carlton Gibson <carlton@noumenal.es>
Co-authored-by: Jake Howard <git@theorangeone.net>

Backport of a07ebec559 from main.
2025-06-04 08:34:51 -03:00
Simon Charette
3340d41446 [5.2.x] Fixed #36432 -- Fixed a prefetch_related crash on related target subclass queryset.
Regression in 626d77e52a.

Refs #36116.

Thanks Cornelis Poppema for the excellent report.

Backport of 08187c94ed from main.
2025-06-04 10:48:13 +02:00
Jake Howard
0c548e62d0 [5.2.x] Fixed #36411 -- Made HttpRequest.get_preferred_type() consider media type parameters.
HttpRequest.get_preferred_type() did not account for parameters in
Accept header media types (e.g., "text/vcard; version=3.0"). This caused
incorrect content negotiation when multiple types differed only by
parameters, reducing specificity as per RFC 7231 section 5.3.2
(https://datatracker.ietf.org/doc/html/rfc7231.html#section-5.3.2).

This fix updates get_preferred_type() to treat media types with
parameters as distinct, allowing more precise and standards-compliant
matching.

Thanks to magicfelix for the report, and to David Sanders and Sarah
Boyce for the reviews.

Backport of c075508b4d from main.
2025-06-03 16:11:38 -03:00
Jacob Walls
2bf4c5b9ea [5.2.x] Fixed #36416 -- Made QuerySet.in_bulk() account for composite pks in id_list.
Backport of 26313bc219 from main.
2025-06-03 17:46:59 +02:00
Blayze
37e5cc6d89 [5.2.x] Fixed #36423 -- Prevented filter_horizontal buttons from intercepting form submission.
In the admin's filter_horizontal widget, optional action buttons like
"Choose all", "Remove all", etc. were changed from `<a>` to `<button>`
elements in #34619, but without specifying `type="button"`. As a result,
when pressing Enter while focused on a form input, these buttons could
be triggered and intercept form submission.

Explicitly set `type="button"` on these control buttons to prevent them
from acting as submit buttons.

Thanks Antoliny Lee for the quick triage and review.

Regression in 857b1048d5.

Backport of 90429625a8 from main.
2025-06-02 22:26:36 -03:00
Adam Johnson
7e4b371eb0 [5.2.x] Fixed #36405 -- Fixed OrderableAggMixin.order_by using OuterRef.
co-authored-by: Simon Charette <charette.s@gmail.com>

Backport of c2615a0500 from main.
2025-05-23 16:23:34 +02:00
Adam Johnson
c29e3092fd [5.2.x] Fixed #36404 -- Fixed Aggregate.filter using OuterRef.
Regression in a76035e925.
Thank you to Simon Charette for the review.

co-authored-by: Simon Charette <charette.s@gmail.com>

Backport of b8e5a8a9a2 from main.
2025-05-23 15:19:50 +02:00
Sarah Boyce
9db932ab4c [5.2.x] Fixed #36390 -- Deprecated RemoteUserMiddleware subclasses missing aprocess_request().
Regression in 50f89ae850.
Thank you to shamoon for the report and Natalia Bidart for the review.

Backport of 1704c49a9b from main.
2025-05-23 10:24:09 +02:00
Natalia
cdd374939a [5.2.x] Added helpers in csrf_tests and logging_tests to assert logs from log_response().
Backport of ad6f998898 from main.
2025-05-22 15:41:13 -03:00
Natalia
2c8358343a [5.2.x] Refs #26688 -- Added tests for log_response() internal helper.
Backport of 8970468159 from main.
2025-05-22 15:40:42 -03:00
Colleen Dunlap
787f3130f7 [5.2.x] Fixed #36388 -- Made QuerySet.union() return self when called with no arguments.
Regression in 9cb8baa0c4.
Thank you to Antoine Humeau for the report and Simon Charette for the review.

Backport of 802baf5da5 from main.
2025-05-19 10:36:08 +02:00
Jacob Walls
6228a35095 [5.2.x] Fixed #36392 -- Raised ValueError when subquery referencing composite pk selects too many columns.
Backport of 994dc6d8a1 from main.
2025-05-16 08:21:18 +02:00
Simon Charette
e23dd72880 [5.2.x] Fixed #36373 -- Fixed select_related() crash on foreign object for a composite pk.
Thanks Jacob Walls for the report and Sarah for the in-depth review.

Backport of 8be0c0d690 from main.
2025-05-12 13:34:45 +02:00
Sarah Boyce
c9731dc656 [5.2.x] Fixed CVE-2025-32873 -- Mitigated potential DoS in strip_tags().
Thanks to Elias Myllymäki for the report, and Shai Berger and Jake
Howard for the reviews.

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

Backport of 9f3419b519 from main.
2025-05-06 22:24:24 -03:00