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

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

index ec41ed39157a930cf8b7dad7a901185f1983d2d1..33ce1b6b569640c6890dc0170d872938c4030acc 100644 (file)
@@ -132,8 +132,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.