Skip to content

Commit e7bb37a

Browse files
Reject unencoded query delimiters in path query input
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 93cb025 commit e7bb37a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

hyperbrowser/client/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ def _build_url(self, path: str) -> str:
9191
raw_query_component = (
9292
stripped_path.split("?", 1)[1] if "?" in stripped_path else ""
9393
)
94+
if "?" in raw_query_component or "#" in raw_query_component:
95+
raise HyperbrowserError(
96+
"path query must not contain unencoded delimiter characters"
97+
)
9498
if any(
9599
character.isspace() or ord(character) < 32 or ord(character) == 127
96100
for character in raw_query_component

tests/test_url_building.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ def test_client_build_url_rejects_empty_or_non_string_paths():
326326
match="path query must not contain unencoded whitespace or control characters",
327327
):
328328
client._build_url("/session?foo=bar baz")
329+
with pytest.raises(
330+
HyperbrowserError,
331+
match="path query must not contain unencoded delimiter characters",
332+
):
333+
client._build_url("/session?foo=bar?baz")
329334
with pytest.raises(
330335
HyperbrowserError,
331336
match="path query must not contain unencoded whitespace or control characters",

0 commit comments

Comments
 (0)