Repository navigation
Conversation
This branch has not been deployed
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.
What kind of change does this PR introduce?
Bug fix. Fixes the
/CheckSumpart of #1531. Thanks to @petervwyatt for the report.The embedded file stream's
/Params /CheckSumwas written asnew String(md5Hex(data)), a literal string holding the 32 hex characters. The PDF specification defines the checksum as a 16-byte string holding the MD5 digest, so veraPDF and pdfcpu reject the 32-byte literal.The checksum is now kept as the digest bytes from
md5Hash, whichPDFObject.convertserialises as a hex string (/CheckSum <...>). The duplicate-attachment check inisEqualcompares the bytes instead of callingtoString().The existing expectations in
tests/unit/attachments.spec.jsnow expect/CheckSum <md5hex>; three of them fail without the fix. The full suite passes (550 tests), and eslint and prettier are clean on the changed files.One thing to be aware of:
PDFObject.convertwritesUint8Arrayvalues without passing them throughencryptFn(that is what keeps the encryption dictionary's/Oand/Uentries intact), so in an encrypted document the checksum is now written unencrypted. PDF/A, where validators check this entry, doesn't allow encryption, so the reported case is not affected. If you'd prefer encrypted documents to get an encrypted hex string here, I'm happy to add that, but it needs a way to tell those byte strings apart from the encryption dictionary ones, so I left it out of this change.The "default to PDF 1.7" part of the issue is left for the maintainers to decide.
Checklist: