python-pip/backport-fix-vulnerable-regex.patch
2023-12-13 14:29:49 +08:00

26 lines
996 B
Diff

From 254e668eef34ca21005634a2bdba9d9a74deaa26 Mon Sep 17 00:00:00 2001
From: M00nL1ght <69127692+SCH227@users.noreply.github.com>
Date: Tue, 30 Aug 2022 05:51:29 +0300
Subject: [PATCH] Fix vulnerable regex
Implement exclusive RE searches to avoid backtracking
---
src/pip/_internal/models/wheel.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pip/_internal/models/wheel.py b/src/pip/_internal/models/wheel.py
index 35c70375539..a5dc12bdd63 100644
--- a/src/pip/_internal/models/wheel.py
+++ b/src/pip/_internal/models/wheel.py
@@ -13,8 +13,8 @@ class Wheel:
"""A wheel file"""
wheel_file_re = re.compile(
- r"""^(?P<namever>(?P<name>.+?)-(?P<ver>.*?))
- ((-(?P<build>\d[^-]*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
+ r"""^(?P<namever>(?P<name>[^\s-]+?)-(?P<ver>[^\s-]*?))
+ ((-(?P<build>\d[^-]*?))?-(?P<pyver>[^\s-]+?)-(?P<abi>[^\s-]+?)-(?P<plat>[^\s-]+?)
\.whl|\.dist-info)$""",
re.VERBOSE,
)