Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parsing errors for some files #38

Merged
merged 2 commits into from
Jul 11, 2022
Merged

fix: parsing errors for some files #38

merged 2 commits into from
Jul 11, 2022

Conversation

pastelmind
Copy link
Collaborator

Fix some bugs that caused some PSD files to fail to parse.

AdditionalLayerInfo ("ALI") blocks with the 'cinf' key use different
byte length for the size field; PSD files use 4 bytes and PSB files use
8.

This is undocumented in Adobe's docs.

Note that this bug previously did not cause parsing to fail, because our
library ignores unrecognized ALI blocks. However, it _may_ have
prevented recognizing valid ALI blocks that come after a 'cinf' block.
ALI blocks are used in two locations inside a PSD file:

- At the end of each Layer Info section. These ALI blocks describe
  properties of each layer. Although Adobe does not name these fields, I
  call them "Extra Info Blocks".
- After the Global Layer Mask Info section. These are called "Tagged
  Blocks", and appear to describe properties of the entire PSD file.

It is known that AdditionalLayerInfo (ALI) blocks are aligned to a
multiple 4 bytes. (This is undocumented in Adobe's docs). However, we
discovered that this only applies to Tagged Blocks, but not Extra Info
Blocks. This caused some PSD files to fail to parse because we were
wrongly enforcing the 4-byte alignment on Extra Info Blocks.

Since our library only parses Extra Info Blocks (completely skipping
Tagged Blocks), we can simply remove the 4-byte aligment code for now.

This issue was reported by @immigration9
@pastelmind pastelmind added the type: bug Something isn't working label Jul 11, 2022
@pastelmind pastelmind self-assigned this Jul 11, 2022
@pastelmind pastelmind merged commit f4fc949 into main Jul 11, 2022
@pastelmind pastelmind deleted the fix-parsing-errors branch July 11, 2022 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant