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