Fix #389: PDFsharp misreads C2PA manifest stream as external file - #391
Open
wooly905 wants to merge 1 commit into
Open
Fix #389: PDFsharp misreads C2PA manifest stream as external file#391wooly905 wants to merge 1 commit into
wooly905 wants to merge 1 commit into
Conversation
Parser.GetStreamLength treated any /F key on a stream dict as an external file stream per PDF 2.0 7.3.8.2, but some producers (e.g. ChatGPT-generated PDFs) misuse /F for embedded-file params instead of /Params. Now only strings or dictionaries that actually look like a file specification (/Type /Filespec, or /FS,/F,/UF,/DOS,/Mac,/Unix) trigger the NotImplementedException; genuine external file streams still throw. Adds PdfSharp.Pdf.C2pa.C2paManager/C2paManifestInfo to read C2PA manifests from a document's /AF array and /EmbeddedFiles name tree, plus a PdfAFRelationship.C2paManifest constant. Wired into PdfDocument and the gdi/wpf mirror csprojs. Adds duck.pdf test asset and 7 xUnit tests covering the fix, manifest reading, and a guard test for real external file streams. Adds a ReadC2paInfo sample app that decodes the manifest's JUMBF/CBOR/COSE structures to verify claim, actions, and signature data end-to-end.
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.
Parser.GetStreamLength treated any /F key on a stream dictionary as an external file stream per PDF 2.0 section 7.3.8.2, but some producers (e.g. ChatGPT-generated PDFs) misuse /F for embedded-file params instead of /Params. This caused NotImplementedException when opening such PDFs.
Now only strings, or dictionaries that actually look like a file specification (/Type /Filespec, or one of /FS, /F, /UF, /DOS, /Mac, /Unix), trigger the exception. Genuine external file streams still throw as before.
Adds PdfSharp.Pdf.C2pa.C2paManager / C2paManifestInfo to read C2PA manifests from a document's /AF array and /EmbeddedFiles name tree, plus a PdfAFRelationship.C2paManifest constant. Wired into PdfDocument and the gdi/wpf mirror csproj files.
Adds a duck.pdf test asset and 7 xUnit tests covering the fix, manifest reading, and a guard test confirming real external file streams still throw. Adds a ReadC2paInfo sample app that decodes the manifest's JUMBF/CBOR/COSE structures to independently verify claim, actions, and signature data.