]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46474: Avoid REDoS in EntryPoint.pattern (sync with importlib_metadata 4.10.1...
authorJason R. Coombs <jaraco@jaraco.com>
Sun, 23 Jan 2022 04:00:23 +0000 (23:00 -0500)
committerGitHub <noreply@github.com>
Sun, 23 Jan 2022 04:00:23 +0000 (23:00 -0500)
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 5ef6d9dc4893d12588934798a2046992538e7a73..371c48220958629799026633e481cdf603144e39 100644 (file)
@@ -156,8 +156,8 @@ class EntryPoint(DeprecatedTuple):
 
     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.