File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,10 @@ def _build_url(self, path: str) -> str:
102102 raise HyperbrowserError ("path must not contain newline characters" )
103103 if any (character .isspace () for character in decoded_path ):
104104 raise HyperbrowserError ("path must not contain whitespace characters" )
105+ if any (
106+ ord (character ) < 32 or ord (character ) == 127 for character in decoded_path
107+ ):
108+ raise HyperbrowserError ("path must not contain control characters" )
105109 normalized_segments = [
106110 segment for segment in decoded_path .split ("/" ) if segment
107111 ]
Original file line number Diff line number Diff line change @@ -146,6 +146,10 @@ def test_client_build_url_rejects_empty_or_non_string_paths():
146146 HyperbrowserError , match = "path must not contain whitespace characters"
147147 ):
148148 client ._build_url ("/session name" )
149+ with pytest .raises (
150+ HyperbrowserError , match = "path must not contain control characters"
151+ ):
152+ client ._build_url ("/session\x00 name" )
149153 with pytest .raises (HyperbrowserError , match = "path must be a relative API path" ):
150154 client ._build_url ("https://api.hyperbrowser.ai/session" )
151155 with pytest .raises (HyperbrowserError , match = "path must be a relative API path" ):
@@ -208,6 +212,10 @@ def test_client_build_url_rejects_empty_or_non_string_paths():
208212 HyperbrowserError , match = "path must not contain whitespace characters"
209213 ):
210214 client ._build_url ("/api/%09segment" )
215+ with pytest .raises (
216+ HyperbrowserError , match = "path must not contain control characters"
217+ ):
218+ client ._build_url ("/api/%00segment" )
211219 finally :
212220 client .close ()
213221
You can’t perform that action at this time.
0 commit comments