From 44bb21e27eaadb5b74a72562260ad40e4b89644c Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 4 Aug 2026 11:29:49 +0200 Subject: [PATCH] [3.12] gh-146333: Fix quadratic regex backtracking in configparser option parsing (GH-146399) (GH-148559) (GH-154081) Use negative lookahead in option regex to prevent backtracking, and to avoid changing logic outside the regexes (since people could use the regex directly). (cherry picked from commit 7e0a0be4097f9d29d66fe23f5af86f18a34ed7dd) (cherry picked from commit a5969e8f0fda37aaf0e2f844fdcfca9d822a70b1) (cherry picked from commit 57558307909b703f669437594778c7482671a3a5) Co-authored-by: Petr Viktorin Co-authored-by: Joshua Swanson <22283299+joshuaswanson@users.noreply.github.com> --- Lib/configparser.py | 8 ++++++-- Lib/test/test_configparser.py | 20 +++++++++++++++++++ ...3-25-00-51-03.gh-issue-146333.LqdL__bn.rst | 3 +++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Security/2026-03-25-00-51-03.gh-issue-146333.LqdL__bn.rst diff --git a/Lib/configparser.py b/Lib/configparser.py index 17707b745f716e4..ff581c6e805bfab 100644 --- a/Lib/configparser.py +++ b/Lib/configparser.py @@ -577,7 +577,9 @@ class RawConfigParser(MutableMapping): \] # ] """ _OPT_TMPL = r""" - (?P