File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ def normalize_base_url(base_url: str) -> str:
3434 normalized_base_url = base_url .strip ().rstrip ("/" )
3535 if not normalized_base_url :
3636 raise HyperbrowserError ("base_url must not be empty" )
37+ if "\n " in normalized_base_url or "\r " in normalized_base_url :
38+ raise HyperbrowserError ("base_url must not contain newline characters" )
3739
3840 parsed_base_url = urlparse (normalized_base_url )
3941 if (
Original file line number Diff line number Diff line change @@ -209,6 +209,11 @@ def test_client_config_rejects_empty_or_invalid_base_url():
209209 with pytest .raises (HyperbrowserError , match = "must not include query parameters" ):
210210 ClientConfig (api_key = "test-key" , base_url = "https://example.local#frag" )
211211
212+ with pytest .raises (
213+ HyperbrowserError , match = "base_url must not contain newline characters"
214+ ):
215+ ClientConfig (api_key = "test-key" , base_url = "https://example.local/\n api" )
216+
212217
213218def test_client_config_normalizes_headers_to_internal_copy ():
214219 headers = {"X-Correlation-Id" : "abc123" }
@@ -313,3 +318,8 @@ def test_client_config_normalize_base_url_validates_and_normalizes():
313318
314319 with pytest .raises (HyperbrowserError , match = "must not include query parameters" ):
315320 ClientConfig .normalize_base_url ("https://example.local?foo=bar" )
321+
322+ with pytest .raises (
323+ HyperbrowserError , match = "base_url must not contain newline characters"
324+ ):
325+ ClientConfig .normalize_base_url ("https://example.local/\n api" )
Original file line number Diff line number Diff line change @@ -98,6 +98,12 @@ def test_client_build_url_rejects_runtime_invalid_base_url_changes():
9898 ):
9999 client ._build_url ("/session" )
100100
101+ client .config .base_url = "https://example.local/\n api"
102+ with pytest .raises (
103+ HyperbrowserError , match = "base_url must not contain newline characters"
104+ ):
105+ client ._build_url ("/session" )
106+
101107 client .config .base_url = " "
102108 with pytest .raises (HyperbrowserError , match = "base_url must not be empty" ):
103109 client ._build_url ("/session" )
You can’t perform that action at this time.
0 commit comments