Skip to content

Commit 075b6f1

Browse files
Reject all scheme-qualified path inputs in URL builder
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 91fc21f commit 075b6f1

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

hyperbrowser/client/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _build_url(self, path: str) -> str:
7575
if "\\" in stripped_path:
7676
raise HyperbrowserError("path must not contain backslashes")
7777
parsed_path = urlparse(stripped_path)
78-
if parsed_path.scheme and parsed_path.netloc:
78+
if parsed_path.scheme:
7979
raise HyperbrowserError("path must be a relative API path")
8080
normalized_path = f"/{stripped_path.lstrip('/')}"
8181
if normalized_path == "/api" or normalized_path.startswith("/api/"):

tests/test_url_building.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def test_client_build_url_rejects_empty_or_non_string_paths():
5555
client._build_url(r"\\session")
5656
with pytest.raises(HyperbrowserError, match="path must be a relative API path"):
5757
client._build_url("https://api.hyperbrowser.ai/session")
58+
with pytest.raises(HyperbrowserError, match="path must be a relative API path"):
59+
client._build_url("mailto:ops@hyperbrowser.ai")
60+
with pytest.raises(HyperbrowserError, match="path must be a relative API path"):
61+
client._build_url("http:example.com")
5862
finally:
5963
client.close()
6064

0 commit comments

Comments
 (0)