]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] bpo-46474: Avoid REDoS in EntryPoint.pattern (sync with importlib_metadata...
authorJason R. Coombs <jaraco@jaraco.com>
Sun, 23 Jan 2022 15:17:41 +0000 (10:17 -0500)
committerGitHub <noreply@github.com>
Sun, 23 Jan 2022 15:17:41 +0000 (10:17 -0500)
(cherry picked from commit 51c3e28c8a163e58dc753765e3cc51d5a717e70d)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Lib/importlib/metadata.py
Misc/NEWS.d/next/Library/2022-01-22-14-49-10.bpo-46474.eKQhvx.rst [new file with mode: 0644]

index 594986ce23efab31b0c307e8497c64423bca46b6..7b8038fd63a8478943eba8ede25a9b99264a6585 100644 (file)
@@ -49,8 +49,8 @@ class EntryPoint(
 
     pattern = re.compile(
         r'(?P<module>[\w.]+)\s*'
-        r'(:\s*(?P<attr>[\w.]+))?\s*'
-        r'(?P<extras>\[.*\])?\s*$'
+        r'(:\s*(?P<attr>[\w.]+)\s*)?'
+        r'((?P<extras>\[.*\])\s*)?$'
         )
     """
     A regular expression describing the syntax for an entry point,
diff --git a/Misc/NEWS.d/next/Library/2022-01-22-14-49-10.bpo-46474.eKQhvx.rst b/Misc/NEWS.d/next/Library/2022-01-22-14-49-10.bpo-46474.eKQhvx.rst
new file mode 100644 (file)
index 0000000..156b7de
--- /dev/null
@@ -0,0 +1,2 @@
+In ``importlib.metadata.EntryPoint.pattern``, avoid potential REDoS by
+limiting ambiguity in consecutive whitespace.