From 93d5b0a5589fabd4e08e0736d625507d20eebedb Mon Sep 17 00:00:00 2001 From: Lee Wintervold Date: Mon, 26 Aug 2024 18:02:12 +0000 Subject: [PATCH] fix: address issues with empty string in `NO_PROXY` --- ldclient/impl/http.py | 5 ++++- ldclient/testing/impl/test_http.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ldclient/impl/http.py b/ldclient/impl/http.py index bb7a262..39941c0 100644 --- a/ldclient/impl/http.py +++ b/ldclient/impl/http.py @@ -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 diff --git a/ldclient/testing/impl/test_http.py b/ldclient/testing/impl/test_http.py index f506c89..8dd0fe1 100644 --- a/ldclient/testing/impl/test_http.py +++ b/ldclient/testing/impl/test_http.py @@ -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),