Fix/png passthrough validation and image copy - #7
Merged
sahebansari merged 4 commits intoSep 27, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.