Skip to content

Commit 551776a

Browse files
Cover nested encoded host-label guardrails in base URL tests
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 9047a08 commit 551776a

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

tests/test_config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,13 @@ def test_client_config_normalize_base_url_validates_and_normalizes():
460460
ClientConfig.normalize_base_url(
461461
f"https://example.local/{deeply_encoded_dot}/api"
462462
)
463+
deeply_encoded_host_label = "%61"
464+
for _ in range(11):
465+
deeply_encoded_host_label = quote(deeply_encoded_host_label, safe="")
466+
with pytest.raises(
467+
HyperbrowserError,
468+
match="base_url host contains excessively nested URL encoding",
469+
):
470+
ClientConfig.normalize_base_url(
471+
f"https://{deeply_encoded_host_label}.example.local"
472+
)

tests/test_url_building.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ def test_client_build_url_rejects_runtime_invalid_base_url_changes():
163163
):
164164
client._build_url("/session")
165165

166+
deeply_encoded_host_label = "%61"
167+
for _ in range(11):
168+
deeply_encoded_host_label = quote(deeply_encoded_host_label, safe="")
169+
client.config.base_url = f"https://{deeply_encoded_host_label}.example.local"
170+
with pytest.raises(
171+
HyperbrowserError,
172+
match="base_url host contains excessively nested URL encoding",
173+
):
174+
client._build_url("/session")
175+
166176
client.config.base_url = "https://example.local%2Fapi"
167177
with pytest.raises(
168178
HyperbrowserError,

0 commit comments

Comments
 (0)