Skip to content

Fix/png passthrough validation and image copy - #7

Merged
sahebansari merged 4 commits into
masterfrom
fix/png-passthrough-validation-and-image-copy
Sep 27, 2026
Merged

sahebansari merged 4 commits into
masterfrom
fix/png-passthrough-validation-and-image-copy

Conversation

@sahebansari

Copy link
Copy Markdown
Owner

No description provided.

RGB and palette PNGs were embedded without decompressing their data, so a
truncated or corrupt file produced a PDF the viewer could not render instead
of an error. Their data is now checked to inflate to the full image, with
valid row filters, before it is embedded as is; anything else goes through the
decoder, which reports it as before. The checked result is kept in the
process-wide image cache, so each distinct image is checked once and later
documents also skip the per-document copy. PNG sizes of 2^31 or more are
rejected.

Image(byte[]) now keeps its own copy of the bytes, which are only read when
the document is saved. The same unchanged buffer passed again reuses its
copy, so repeated placements still allocate nothing.

Adds RgbPngDocumentColdCache to the image benchmarks.
InvalidDataException is not an IOException, so a PNG that passed validation but failed to decode escaped PdfSpecRenderer instead of returning an error the model can act on.
@sahebansari sahebansari self-assigned this Sep 27, 2026

@sahebansari sahebansari left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sahebansari
sahebansari merged commit 40613fb into master Sep 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant