Skip to content

Commit 6e4eb09

Browse files
committed
[3.8] bpo-46474: Avoid REDoS in EntryPoint.pattern (sync with importlib_metadata 4.10.1) (GH-30803).
(cherry picked from commit 51c3e28) Co-authored-by: Jason R. Coombs <[email protected]>
1 parent 7c5b01b commit 6e4eb09

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/importlib/metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class EntryPoint(
4949

5050
pattern = re.compile(
5151
r'(?P<module>[\w.]+)\s*'
52-
r'(:\s*(?P<attr>[\w.]+))?\s*'
53-
r'(?P<extras>\[.*\])?\s*$'
52+
r'(:\s*(?P<attr>[\w.]+)\s*)?'
53+
r'((?P<extras>\[.*\])\s*)?$'
5454
)
5555
"""
5656
A regular expression describing the syntax for an entry point,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
In ``importlib.metadata.EntryPoint.pattern``, avoid potential REDoS by
2+
limiting ambiguity in consecutive whitespace.

0 commit comments

Comments
 (0)