Allow compressed resource header length field to be 0 (see #10)

This commit is contained in:
dgelessus 2023-02-14 21:31:45 +01:00
parent 8f60fcdfc4
commit a2663ae85d
2 changed files with 4 additions and 2 deletions

View File

@ -128,6 +128,8 @@ see the ["resource forks" section of the mac_file_format_docs repo](https://gith
* Added `open` and `open_raw` methods to `Resource` objects,
for stream-based access to resource data.
* Fixed reading of compressed resource headers with the header length field incorrectly set to 0
(because real Mac OS apparently accepts this).
### Version 1.8.0

View File

@ -46,8 +46,8 @@ class CompressedHeaderInfo(object):
raise DecompressError("Invalid header")
if signature != COMPRESSED_SIGNATURE:
raise DecompressError(f"Invalid signature: {signature!r}, expected {COMPRESSED_SIGNATURE!r}")
if header_length != 0x12:
raise DecompressError(f"Unsupported header length: 0x{header_length:>04x}, expected 0x12")
if header_length not in {0, 0x12}:
raise DecompressError(f"Unsupported header length value: 0x{header_length:>04x}, expected 0x12 or 0")
if compression_type == COMPRESSED_TYPE_8:
working_buffer_fractional_size, expansion_buffer_size, dcmp_id, reserved = STRUCT_COMPRESSED_TYPE_8_HEADER.unpack(remainder)