File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,6 +40,11 @@ def normalize_base_url(base_url: str) -> str:
4040 raise HyperbrowserError ("base_url must not contain whitespace characters" )
4141 if "\\ " in normalized_base_url :
4242 raise HyperbrowserError ("base_url must not contain backslashes" )
43+ if any (
44+ ord (character ) < 32 or ord (character ) == 127
45+ for character in normalized_base_url
46+ ):
47+ raise HyperbrowserError ("base_url must not contain control characters" )
4348
4449 parsed_base_url = urlparse (normalized_base_url )
4550 if (
Original file line number Diff line number Diff line change @@ -222,6 +222,10 @@ def test_client_config_rejects_empty_or_invalid_base_url():
222222 HyperbrowserError , match = "base_url must not contain backslashes"
223223 ):
224224 ClientConfig (api_key = "test-key" , base_url = "https://example.local\\ api" )
225+ with pytest .raises (
226+ HyperbrowserError , match = "base_url must not contain control characters"
227+ ):
228+ ClientConfig (api_key = "test-key" , base_url = "https://example.local\x00 api" )
225229
226230
227231def test_client_config_normalizes_headers_to_internal_copy ():
@@ -341,3 +345,7 @@ def test_client_config_normalize_base_url_validates_and_normalizes():
341345 HyperbrowserError , match = "base_url must not contain backslashes"
342346 ):
343347 ClientConfig .normalize_base_url ("https://example.local\\ api" )
348+ with pytest .raises (
349+ HyperbrowserError , match = "base_url must not contain control characters"
350+ ):
351+ ClientConfig .normalize_base_url ("https://example.local\x00 api" )
Original file line number Diff line number Diff line change @@ -116,6 +116,12 @@ def test_client_build_url_rejects_runtime_invalid_base_url_changes():
116116 ):
117117 client ._build_url ("/session" )
118118
119+ client .config .base_url = "https://example.local\x00 api"
120+ with pytest .raises (
121+ HyperbrowserError , match = "base_url must not contain control characters"
122+ ):
123+ client ._build_url ("/session" )
124+
119125 client .config .base_url = " "
120126 with pytest .raises (HyperbrowserError , match = "base_url must not be empty" ):
121127 client ._build_url ("/session" )
You can’t perform that action at this time.
0 commit comments