Fix page dict string value corruption in createIncPageUpdate#134
Draft
fredgig wants to merge 1 commit intodigitorus:mainfrom
Draft
Fix page dict string value corruption in createIncPageUpdate#134fredgig wants to merge 1 commit intodigitorus:mainfrom
fredgig wants to merge 1 commit intodigitorus:mainfrom
Conversation
Member
|
Please note that #126 is going te replace the current main branch when ready. |
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.
Bug
createIncPageUpdatewrites page dictionary string values (like/LastModified,/CreationDate) using Go double quotes instead of PDF parenthesized strings.This breaks multi-signature PDFs. After the first signature rewrites the page dict, subsequent calls to
pdf.NewReaderpanic:Root Cause
The
defaultcase usespage.Key(key).String()to serialize values.Value.String()callsobjfmt(), which runsstrconv.Quote()on string values, producing"text"instead of(text).default: page_buffer.WriteString(fmt.Sprintf(" /%s %s\n", key, page.Key(key).String()))A page entry like:
Gets rewritten as:
Double quotes aren't valid PDF string syntax. The lexer treats it as an unexpected keyword and panics.
Repro
/LastModified)Fix
Check for
pdf.Stringkind and usepdfString(val.RawString())instead ofval.String().pdfString()insign/helpers.goescapes\,(,),\rand wraps in(...).RawString()gives the unescaped bytes,pdfString()re-escapes for valid PDF output.Fixes #132