From: Joshua Swanson <22283299+joshuaswanson@users.noreply.github.com>
Date: Tue, 7 Apr 2026 14:10:34 +0000 (+0200)
Subject: gh-146333: Fix quadratic regex backtracking in configparser option parsing (GH-146399)
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e0a0be4097f9d29d66fe23f5af86f18a34ed7dd;p=thirdparty%2FPython%2Fcpython.git
gh-146333: Fix quadratic regex backtracking in configparser option parsing (GH-146399)
Use negative lookahead in option regex to prevent backtracking, and to avoid changing logic outside the regexes (since people could use the regex directly).
---
diff --git a/Lib/configparser.py b/Lib/configparser.py
index d435a5c2fe0d..e76647d339e9 100644
--- a/Lib/configparser.py
+++ b/Lib/configparser.py
@@ -613,7 +613,9 @@ class RawConfigParser(MutableMapping):
\] # ]
"""
_OPT_TMPL = r"""
- (?P