Repository navigation
đ Escape appName as a PDF name in Prop_Build - #336
fstandhartinger wants to merge 3 commits into
Conversation
appName was written into /Prop_Build /App /Name verbatim, so a value with a space, a delimiter or a non-ASCII character produced an invalid dictionary (e.g. "/Name /My App"). Add escapePdfName to @signpdf/utils (ISO 32000-1 7.3.5: UTF-8 bytes outside ! to ~, delimiters and # become #xx) and use it in placeholder-pdfkit and placeholder-pdfkit010, which placeholder-plain goes through. Names that need no escaping are unchanged. placeholder-pdf-lib already escapes through pdf-lib's PDFName. utils/dist is updated for the new export because the pdfkit-compatibility CI job tests placeholder-pdfkit against the committed utils build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
placeholder-plain's tests and CI import placeholder-pdfkit010 from its committed dist, so the escaping has to be in the build. Generated with `lerna run build`; the other differences in these two files are the existing src (removed eslint comments, the widget's /P entry) that the committed build did not have yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
[P2] Emit uppercase hex escapes at pdf-lib 1.17.1 only decodes uppercase hex escapes. I reproduced PDFKit output with All 123 tests across the four affected packages passed, with coverage thresholds met. <Reviewed with GPT-6.1 Sol> |
pdf-lib 1.17.1 only decodes uppercase #XX escapes in names, so an appName like "Résumé" written as R#c3#a9sum#c3#a9 was read back literally and re-serialized as R#23c3#23a9..., changing the metadata. Uppercase escapes round-trip through pdf-lib. Adds a pdf-lib round-trip test (fails with lowercase escapes) and pdf-lib as a devDependency of @signpdf/utils (already in yarn.lock via placeholder-pdf-lib). utils/dist rebuilt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bf81c97 to
7afda81
Compare
|
Thanks, confirmed and fixed in 7afda81. I reproduced it first:
The PR description now shows the uppercase form as well. (Prepared with Claude Code.) |
Fixes #335.
appNamewas written into/Prop_Build /App /Nameas a PDF name without escaping, soMy Appcame out as/Name /My Appand poppler reportedDictionary key must be a name object.Change
@signpdf/utilsgetsescapePdfName(ISO 32000-1 §7.3.5): the value is encoded as UTF-8, and every byte outside!â~, every delimiter and#itself is written as#XX(uppercase hex, which pdf-lib decodes). Values that need no escaping come back unchanged, sosignpdf/app-name-signpdfproduce the same bytes as before.placeholder-pdfkitandplaceholder-pdfkit010escapeappNamebefore handing it to the writer.placeholder-plaingoes throughplaceholder-pdfkit010, so it is covered too.placeholder-pdf-libis unchanged, because pdf-lib'sPDFNamealready escapes.escapePdfName, plus oneappName: 'My App'case in each of the three placeholder packages. All three placeholder cases fail ondevelopand pass with the change.About
dist: I committed the rebuiltutils/dist(new export) and the twopdfkitAddPlaceholder.jsbuilds, because the pdfkit-compatibility job andplaceholder-plain's tests import the committed builds. The other lines that changed in those two files come fromsrcthat the committed build didn't include yet (removed eslint comments, the widget's/P). I left every otherdistfile alone.Checked locally (Node 26,
lerna run lintandlerna run testgreen, coverage thresholds met;placeholder-pdfkitalso against pdfkit 0.15.0):appName/Appbefore/AppafterMy App<< /Name /My App >><< /Name /My#20App >>My App<< /Name /My App >><< /Name /My#20App >>My App<< /Name /My App >><< /Name /My#20App >>Résumé (signer)/R#C3#A9sum#C3#A9#20#28signer#29The pdfkit-based placeholders were affected as well, as the issue suspected. Every output was then signed with
signpdf.signand the test P12 certificate, andpdfsigreports "Signature is Valid" for each of them.I used Claude Code (AI) to help write this change. I reviewed it and ran everything above myself.
đ€ Generated with Claude Code