|
| 1 | +import platform |
1 | 2 | import sys |
2 | 3 | import zipfile |
3 | 4 | from pathlib import Path |
|
16 | 17 | process_file, |
17 | 18 | remove_inner_chunks, |
18 | 19 | ) |
19 | | -from unblob.report import ExtractDirectoryExistsReport |
| 20 | +from unblob.report import ExtractDirectoryExistsReport, StatReport |
20 | 21 |
|
21 | 22 |
|
22 | 23 | def assert_same_chunks(expected, actual, explanation=None): |
@@ -277,3 +278,36 @@ def test_process_file_prevents_double_extracts(tmp_path: Path, fw: Path): |
277 | 278 | assert outsiders == [extracted_fw_zip] |
278 | 279 |
|
279 | 280 | assert extracted_extracted_fw_paths == [Path("."), *extracted_fw_paths] |
| 281 | + |
| 282 | + |
| 283 | +@pytest.mark.skipif( |
| 284 | + platform.system() == "Darwin", reason="non-POSIX path not supported" |
| 285 | +) |
| 286 | +def test_processing_with_non_posix_paths(tmp_path: Path): |
| 287 | + non_unicode_file = tmp_path / "file-\udce4\udc94" |
| 288 | + non_unicode_file.write_bytes(b"content") |
| 289 | + |
| 290 | + directory = tmp_path / "dir-\udce4\udc94" |
| 291 | + directory.mkdir(exist_ok=True) |
| 292 | + file_with_non_unicode_dir = directory / "test.txt" |
| 293 | + file_with_non_unicode_dir.write_bytes(b"content") |
| 294 | + |
| 295 | + extract_root = tmp_path / "extract_root" |
| 296 | + config = ExtractionConfig(extract_root=extract_root, entropy_depth=0) |
| 297 | + |
| 298 | + for path in (non_unicode_file, file_with_non_unicode_dir): |
| 299 | + process_result = process_file(config, path) |
| 300 | + assert process_result.errors == [] |
| 301 | + assert len(process_result.results) == 1 |
| 302 | + assert len(process_result.results[0].reports) == 3 |
| 303 | + |
| 304 | + report = process_result.results[0].reports[0] |
| 305 | + assert isinstance(report, StatReport) |
| 306 | + assert report == StatReport( |
| 307 | + path=path, |
| 308 | + size=7, |
| 309 | + is_dir=False, |
| 310 | + is_file=True, |
| 311 | + is_link=False, |
| 312 | + link_target=None, |
| 313 | + ) |
0 commit comments