Skip to content

Commit

Permalink
fix: Skip empty hosts when processing NO_PROXY variable (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpelwintervold committed Aug 26, 2024
1 parent 67cd411 commit 82d8117
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ldclient/impl/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@ def _get_proxy_url(target_base_uri):
return proxy_url

for no_proxy_entry in no_proxy.split(','):
if no_proxy_entry == '':
continue
parts = no_proxy_entry.strip().split(':')
if len(parts) == 1:
if target_host.endswith(no_proxy_entry):
return None
continue

if parts[0] == '':
continue
if target_host.endswith(parts[0]) and target_port == int(parts[1]):
return None

Expand Down
3 changes: 3 additions & 0 deletions ldclient/testing/impl/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
('https://secure.example.com', 'wrong.example.com', 'https://secure.proxy:1234'),
('https://secure.example.com:8080', 'secure.example.com', None),
('https://secure.example.com:8080', 'secure.example.com:443', 'https://secure.proxy:1234'),
('https://secure.example.com:8080', 'secure.example.com:443,', 'https://secure.proxy:1234'),
('https://secure.example.com:8080', 'secure.example.com:443,,', 'https://secure.proxy:1234'),
('https://secure.example.com:8080', ':8080', 'https://secure.proxy:1234'),
('https://secure.example.com', 'example.com', None),
('https://secure.example.com', 'example.com:443', None),
Expand Down

0 comments on commit 82d8117

Please sign in to comment.