diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-05-08 09:47:53 -0400 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-05-13 10:54:01 -0400 |
| commit | 952f42e958e5887fb297ec4d5607ceec5e1bf20b (patch) | |
| tree | b69a90e8324ba4747a3b604748472472ab13bea0 | |
| parent | 335c6d0129400eda792f3bec5c71bb28af5e5d37 (diff) | |
Refs CVE-2025-64460 -- Removed workaround for minidom document checks.
CVE-2025-12084 was fixed upstream in CPython and backported to
3.14.2, 3.13.11, and 3.12.13, making this workaround unnecessary.
https://github.com/python/cpython/issues/142145
| -rw-r--r-- | django/core/serializers/xml_serializer.py | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/django/core/serializers/xml_serializer.py b/django/core/serializers/xml_serializer.py index 6d3005ac40..366e077c78 100644 --- a/django/core/serializers/xml_serializer.py +++ b/django/core/serializers/xml_serializer.py @@ -3,8 +3,7 @@ XML serializer. """ import json -from contextlib import contextmanager -from xml.dom import minidom, pulldom +from xml.dom import pulldom from xml.sax import handler from xml.sax.expatreader import ExpatParser as _ExpatParser @@ -16,25 +15,6 @@ from django.db import DEFAULT_DB_ALIAS, models from django.utils.xmlutils import SimplerXMLGenerator, UnserializableContentError -@contextmanager -def fast_cache_clearing(): - """Workaround for performance issues in minidom document checks. - - Speeds up repeated DOM operations by skipping unnecessary full traversal - of the DOM tree. - """ - module_helper_was_lambda = False - if original_fn := getattr(minidom, "_in_document", None): - module_helper_was_lambda = original_fn.__name__ == "<lambda>" - if not module_helper_was_lambda: - minidom._in_document = lambda node: bool(node.ownerDocument) - try: - yield - finally: - if original_fn and not module_helper_was_lambda: - minidom._in_document = original_fn - - class Serializer(base.Serializer): """Serialize a QuerySet to XML.""" @@ -267,8 +247,7 @@ class Deserializer(base.Deserializer): def __next__(self): for event, node in self.event_stream: if event == "START_ELEMENT" and node.nodeName == "object": - with fast_cache_clearing(): - self.event_stream.expandNode(node) + self.event_stream.expandNode(node) return self._handle_object(node) raise StopIteration |
