Skip to content

Commit 0ba6277

Browse files
Treat whitespace-only file paths as empty
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent cdefe70 commit 0ba6277

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

hyperbrowser/client/file_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def ensure_existing_file_path(
2020
) from exc
2121
if not isinstance(normalized_path, str):
2222
raise HyperbrowserError("file_path must resolve to a string path")
23-
if not normalized_path:
23+
if not normalized_path.strip():
2424
raise HyperbrowserError("file_path must not be empty")
2525
if "\x00" in normalized_path:
2626
raise HyperbrowserError("file_path must not contain null bytes")

tests/test_file_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def test_ensure_existing_file_path_rejects_empty_string_paths():
8080
missing_file_message="missing",
8181
not_file_message="not-file",
8282
)
83+
with pytest.raises(HyperbrowserError, match="file_path must not be empty"):
84+
ensure_existing_file_path(
85+
" ",
86+
missing_file_message="missing",
87+
not_file_message="not-file",
88+
)
8389

8490

8591
def test_ensure_existing_file_path_rejects_null_byte_paths():

0 commit comments

Comments
 (0)