]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.8] bpo-46474: Avoid REDoS in EntryPoint.pattern (sync with importlib_metadata...
authorJason R. Coombs <jaraco@jaraco.com>
Mon, 14 Feb 2022 17:56:03 +0000 (12:56 -0500)
committerGitHub <noreply@github.com>
Mon, 14 Feb 2022 17:56:03 +0000 (18:56 +0100)
(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 9d2285cb4d46dd0e14538fcbf042aa9d49bcc6f0..c8d533c5c2b320e76e89d001ed47a4c47a7544a0 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.