Repository navigation
fix(pdf): read Info values pdf-lib can't type - #26
Merged
Merged
Conversation
pdf-lib's Info getters throw on a date written as text or left empty, and on a title, author or keywords that aren't strings. An impossible date comes back as an Invalid Date, and toISOString then throws. Any of these failed the whole file as a crash: the person was told it may be damaged, and all of its metadata stayed in place. stripPdf now falls back to the value the file actually holds, so the field is reported and removed like any other.
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.
Summary
An Info value pdf-lib can't type no longer fails the file. It falls back to the value the file holds.
Monday, 5 Januarycrash: ErrorD:20261399120000Zcrash: RangeErrorcrash: Errorcrash: ErrorThis also mattered for privacy: a crashed file kept all its metadata, and the person was told it may be damaged.
Evidence
It may be damaged....After: 326 tests pass, typecheck and lint clean.
Built site in headless Chrome with the PDF that crashed:
Monday, 5 Januaryshown, no failed card or email link,-1 removed, "Re-checked the cleaned file: no metadata left."The
a crashtests used a bad date as their trigger, so they now mocksetTitleandsave.info:andsavesteps stay covered.Merge Danger
Door: two-way
Blast Radius: PDFs
Only changes what happens when pdf-lib can't read an Info value, which used to always fail. Fields it reads normally are unchanged. A non-date raw value now appears in the report as the file wrote it, in the person's own browser only; it doesn't go to telemetry.
The two production crashes aren't proven to be this bug, as neither file can be inspected. A new
crash: Error at xmp,customorsavewould mean there's a second cause.