File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ def _build_url(self, path: str) -> str:
100100 raise HyperbrowserError ("path must not contain backslashes" )
101101 if "\n " in decoded_path or "\r " in decoded_path :
102102 raise HyperbrowserError ("path must not contain newline characters" )
103+ if any (character .isspace () for character in decoded_path ):
104+ raise HyperbrowserError ("path must not contain whitespace characters" )
103105 normalized_segments = [
104106 segment for segment in decoded_path .split ("/" ) if segment
105107 ]
Original file line number Diff line number Diff line change @@ -136,6 +136,10 @@ def test_client_build_url_rejects_empty_or_non_string_paths():
136136 HyperbrowserError , match = "path must not contain newline characters"
137137 ):
138138 client ._build_url ("/session\n next" )
139+ with pytest .raises (
140+ HyperbrowserError , match = "path must not contain whitespace characters"
141+ ):
142+ client ._build_url ("/session name" )
139143 with pytest .raises (HyperbrowserError , match = "path must be a relative API path" ):
140144 client ._build_url ("https://api.hyperbrowser.ai/session" )
141145 with pytest .raises (HyperbrowserError , match = "path must be a relative API path" ):
@@ -182,6 +186,14 @@ def test_client_build_url_rejects_empty_or_non_string_paths():
182186 HyperbrowserError , match = "path must not contain newline characters"
183187 ):
184188 client ._build_url ("/api/%250Asegment" )
189+ with pytest .raises (
190+ HyperbrowserError , match = "path must not contain whitespace characters"
191+ ):
192+ client ._build_url ("/api/%20segment" )
193+ with pytest .raises (
194+ HyperbrowserError , match = "path must not contain whitespace characters"
195+ ):
196+ client ._build_url ("/api/%09segment" )
185197 finally :
186198 client .close ()
187199
You can’t perform that action at this time.
0 commit comments