at master 992 B view raw
1From 57acb7c26d809cf864ec439b8bcd6364702022d5 Mon Sep 17 00:00:00 2001 2From: Nate Prewitt <nate.prewitt@gmail.com> 3Date: Wed, 25 Sep 2024 08:03:20 -0700 4Subject: [PATCH] Only use hostname to do netrc lookup instead of netloc 5 6--- 7 src/requests/utils.py | 8 +------- 8 1 file changed, 1 insertion(+), 7 deletions(-) 9 10diff --git a/src/requests/utils.py b/src/requests/utils.py 11index 699683e5d9..8a307ca8a0 100644 12--- a/src/requests/utils.py 13+++ b/src/requests/utils.py 14@@ -236,13 +236,7 @@ def get_netrc_auth(url, raise_errors=False): 15 return 16 17 ri = urlparse(url) 18- 19- # Strip port numbers from netloc. This weird `if...encode`` dance is 20- # used for Python 3.2, which doesn't support unicode literals. 21- splitstr = b":" 22- if isinstance(url, str): 23- splitstr = splitstr.decode("ascii") 24- host = ri.netloc.split(splitstr)[0] 25+ host = ri.hostname 26 27 try: 28 _netrc = netrc(netrc_path).authenticators(host)