{"title":"Django 4.2.21 release notes","version":"dev","locale":"en","docname":"releases/4.2.21","url":"/en/dev/releases/4.2.21/","canonical":"https://djangodocs.dev/en/dev/releases/4.2.21/","summary":"Django 4.2.21 fixes a security issue with severity “moderate”, a data loss bug, and a regression in 4.2.20.","html":"<h1>Django 4.2.21 release notes<a class=\"heading-anchor\" href=\"#django-4-2-21-release-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><em>May 7, 2025</em></p>\n<p>Django 4.2.21 fixes a security issue with severity “moderate”, a data loss bug,\nand a regression in 4.2.20.</p>\n<p>This release was built using an upgraded <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/setuptools/\">setuptools</a>, producing\nfilenames compliant with <span class=\"target\" id=\"index-0\"></span><a class=\"pep reference external\" href=\"https://peps.python.org/pep-0491/\"><strong>PEP 491</strong></a> and <span class=\"target\" id=\"index-1\"></span><a class=\"pep reference external\" href=\"https://peps.python.org/pep-0625/\"><strong>PEP 625</strong></a> and thus addressing a PyPI\nwarning about non-compliant distribution filenames. This change only affects\nthe Django packaging process and does not impact Django’s behavior.</p>\n<section id=\"cve-2025-32873-denial-of-service-possibility-in-strip-tags\">\n<h2>CVE-2025-32873: Denial-of-service possibility in <code class=\"docutils literal notranslate\">strip_tags()</code><a class=\"heading-anchor\" href=\"#cve-2025-32873-denial-of-service-possibility-in-strip-tags\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p><a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.strip_tags\" title=\"django.utils.html.strip_tags\"><code class=\"xref py py-func docutils literal notranslate\">strip_tags()</code></a> would be slow to evaluate certain inputs\ncontaining large sequences of incomplete HTML tags. This function is used to\nimplement the <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-striptags\"><code class=\"xref std std-tfilter docutils literal notranslate\">striptags</code></a> template filter, which was thus also\nvulnerable.</p>\n<p><a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.strip_tags\" title=\"django.utils.html.strip_tags\"><code class=\"xref py py-func docutils literal notranslate\">strip_tags()</code></a> now raises a <a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.core.exceptions.SuspiciousOperation\" title=\"django.core.exceptions.SuspiciousOperation\"><code class=\"xref py py-exc docutils literal notranslate\">SuspiciousOperation</code></a>\nexception if it encounters an unusually large number of unclosed opening tags.</p>\n</section>\n<section id=\"bugfixes\">\n<h2>Bugfixes<a class=\"heading-anchor\" href=\"#bugfixes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<ul class=\"simple\">\n<li><p>Fixed a data corruption possibility in <code class=\"docutils literal notranslate\">file_move_safe()</code> when\n<code class=\"docutils literal notranslate\">allow_overwrite=True</code>, where leftover content from a previously larger\nfile could remain after overwriting with a smaller one due to lack of\ntruncation (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36298\">#36298</a>).</p></li>\n<li><p>Fixed a regression in Django 4.2.20, introduced when fixing\n<span class=\"target\" id=\"index-2\"></span><a class=\"cve reference external\" href=\"https://www.cve.org/CVERecord?id=CVE-2025-26699\"><strong>CVE 2025-26699</strong></a>, where the <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-wordwrap\"><code class=\"xref std std-tfilter docutils literal notranslate\">wordwrap</code></a> template filter did not\npreserve empty lines between paragraphs after wrapping text\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36341\">#36341</a>).</p></li>\n</ul>\n</section>","rootId":"django-4-2-21-release-notes","toc":[{"title":"CVE-2025-32873: Denial-of-service possibility in strip_tags()","anchor":"cve-2025-32873-denial-of-service-possibility-in-strip-tags","children":[]},{"title":"Bugfixes","anchor":"bugfixes","children":[]}],"breadcrumbs":[{"docname":"releases/index","title":"Release notes","url":"/en/dev/releases/"}],"prev":{"docname":"releases/4.2.22","title":"Django 4.2.22 release notes","url":"/en/dev/releases/4.2.22/"},"next":{"docname":"releases/4.2.20","title":"Django 4.2.20 release notes","url":"/en/dev/releases/4.2.20/"},"formats":{"html":"/en/dev/releases/4.2.21/","markdown":"/en/dev/releases/4.2.21.md","json":"/en/dev/releases/4.2.21.json"},"source":"https://github.com/django/django/blob/main/docs/releases/4.2.21.txt","official":"https://docs.djangoproject.com/en/dev/releases/4.2.21/","inVersions":["dev","6.1","6.0","5.2","5.1","4.2"],"inLocales":["en"]}