Skip to content

Commit 82d8117

Browse files
fix: Skip empty hosts when processing NO_PROXY variable (#309)
1 parent 67cd411 commit 82d8117

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ldclient/impl/http.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,15 @@ def _get_proxy_url(target_base_uri):
120120
return proxy_url
121121

122122
for no_proxy_entry in no_proxy.split(','):
123+
if no_proxy_entry == '':
124+
continue
123125
parts = no_proxy_entry.strip().split(':')
124126
if len(parts) == 1:
125127
if target_host.endswith(no_proxy_entry):
126128
return None
127129
continue
128-
130+
if parts[0] == '':
131+
continue
129132
if target_host.endswith(parts[0]) and target_port == int(parts[1]):
130133
return None
131134

ldclient/testing/impl/test_http.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
('https://secure.example.com', 'wrong.example.com', 'https://secure.proxy:1234'),
1717
('https://secure.example.com:8080', 'secure.example.com', None),
1818
('https://secure.example.com:8080', 'secure.example.com:443', 'https://secure.proxy:1234'),
19+
('https://secure.example.com:8080', 'secure.example.com:443,', 'https://secure.proxy:1234'),
20+
('https://secure.example.com:8080', 'secure.example.com:443,,', 'https://secure.proxy:1234'),
21+
('https://secure.example.com:8080', ':8080', 'https://secure.proxy:1234'),
1922
2023
('https://secure.example.com', 'example.com', None),
2124
('https://secure.example.com', 'example.com:443', None),

0 commit comments

Comments
 (0)