File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,10 @@ def _build_url(self, path: str) -> str:
9191 f"?{ normalized_parts .query } " if normalized_parts .query else ""
9292 )
9393 decoded_path = unquote (normalized_path_only )
94+ if "\\ " in decoded_path :
95+ raise HyperbrowserError ("path must not contain backslashes" )
96+ if "\n " in decoded_path or "\r " in decoded_path :
97+ raise HyperbrowserError ("path must not contain newline characters" )
9498 normalized_segments = [
9599 segment for segment in decoded_path .split ("/" ) if segment
96100 ]
Original file line number Diff line number Diff line change @@ -156,6 +156,14 @@ def test_client_build_url_rejects_empty_or_non_string_paths():
156156 HyperbrowserError , match = "path must not contain relative path segments"
157157 ):
158158 client ._build_url ("/api/%2E/session" )
159+ with pytest .raises (
160+ HyperbrowserError , match = "path must not contain backslashes"
161+ ):
162+ client ._build_url ("/api/%5Csession" )
163+ with pytest .raises (
164+ HyperbrowserError , match = "path must not contain newline characters"
165+ ):
166+ client ._build_url ("/api/%0Asegment" )
159167 finally :
160168 client .close ()
161169
You can’t perform that action at this time.
0 commit comments