summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-01-23 15:17:41 (GMT)
committerGitHub <noreply@github.com>2022-01-23 15:17:41 (GMT)
commit1514d1252f96e6a83eb65c439522a6b5443f6a1a (patch)
tree06c07df4577e985e9ac8797efcb2315645637222
parentd0852c447aae650b665aaad61d914a1dc4d7ad96 (diff)
downloadcpython-1514d1252f96e6a83eb65c439522a6b5443f6a1a.zip
cpython-1514d1252f96e6a83eb65c439522a6b5443f6a1a.tar.gz
cpython-1514d1252f96e6a83eb65c439522a6b5443f6a1a.tar.bz2
[3.9] bpo-46474: Avoid REDoS in EntryPoint.pattern (sync with importlib_metadata 4.10.1) (GH-30803). (GH-30828)
(cherry picked from commit 51c3e28c8a163e58dc753765e3cc51d5a717e70d) Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
-rw-r--r--Lib/importlib/metadata.py4
-rw-r--r--Misc/NEWS.d/next/Library/2022-01-22-14-49-10.bpo-46474.eKQhvx.rst2
2 files changed, 4 insertions, 2 deletions
diff --git a/Lib/importlib/metadata.py b/Lib/importlib/metadata.py
index 594986c..7b8038f 100644
--- a/Lib/importlib/metadata.py
+++ b/Lib/importlib/metadata.py
@@ -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
index 0000000..156b7de
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-01-22-14-49-10.bpo-46474.eKQhvx.rst
@@ -0,0 +1,2 @@
+In ``importlib.metadata.EntryPoint.pattern``, avoid potential REDoS by
+limiting ambiguity in consecutive whitespace.