orion / rpms / python3x-pip

Forked from rpms/python3x-pip 2 years ago
Clone
1e5ef6
From 6d2dcef3427b96c36ddfebf217f774a2c5ecad38 Mon Sep 17 00:00:00 2001
1e5ef6
From: Lumir Balhar <lbalhar@redhat.com>
1e5ef6
Date: Wed, 30 Jun 2021 09:27:07 +0200
1e5ef6
Subject: [PATCH] CVE-2021-33503
1e5ef6
1e5ef6
---
1e5ef6
 src/pip/_vendor/urllib3/util/url.py | 8 +++++---
1e5ef6
 1 file changed, 5 insertions(+), 3 deletions(-)
1e5ef6
1e5ef6
diff --git a/src/pip/_vendor/urllib3/util/url.py b/src/pip/_vendor/urllib3/util/url.py
1e5ef6
index 5fe37a7..addaeb7 100644
1e5ef6
--- a/src/pip/_vendor/urllib3/util/url.py
1e5ef6
+++ b/src/pip/_vendor/urllib3/util/url.py
1e5ef6
@@ -63,12 +63,12 @@ IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT + "$")
1e5ef6
 BRACELESS_IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT[2:-2] + "$")
1e5ef6
 ZONE_ID_RE = re.compile("(" + ZONE_ID_PAT + r")\]$")
1e5ef6
 
1e5ef6
-SUBAUTHORITY_PAT = (u"^(?:(.*)@)?(%s|%s|%s)(?::([0-9]{0,5}))?$") % (
1e5ef6
+_HOST_PORT_PAT = ("^(%s|%s|%s)(?::([0-9]{0,5}))?$") % (
1e5ef6
     REG_NAME_PAT,
1e5ef6
     IPV4_PAT,
1e5ef6
     IPV6_ADDRZ_PAT,
1e5ef6
 )
1e5ef6
-SUBAUTHORITY_RE = re.compile(SUBAUTHORITY_PAT, re.UNICODE | re.DOTALL)
1e5ef6
+_HOST_PORT_RE = re.compile(_HOST_PORT_PAT, re.UNICODE | re.DOTALL)
1e5ef6
 
1e5ef6
 UNRESERVED_CHARS = set(
1e5ef6
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~"
1e5ef6
@@ -374,7 +374,9 @@ def parse_url(url):
1e5ef6
             scheme = scheme.lower()
1e5ef6
 
1e5ef6
         if authority:
1e5ef6
-            auth, host, port = SUBAUTHORITY_RE.match(authority).groups()
1e5ef6
+            auth, _, host_port = authority.rpartition("@")
1e5ef6
+            auth = auth or None
1e5ef6
+            host, port = _HOST_PORT_RE.match(host_port).groups()
1e5ef6
             if auth and normalize_uri:
1e5ef6
                 auth = _encode_invalid_chars(auth, USERINFO_CHARS)
1e5ef6
             if port == "":
1e5ef6
-- 
1e5ef6
2.31.1
1e5ef6