fix(pdf): accept owner-password PDFs that open with an empty user password (Fixes #3303) - #3350
ssmurfgg04-gif wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey there, it looks like you haven't accepted our contributor license agreement yet. In order for us to accept your pull request we ask that you please fill out the CLA: |
|
Signed the CLA just now, the check should clear shortly. Thanks for the pointer. |
Fixes #3303.
What changed
normalizePdfno longer rejects every PDF that carries an encryption dictionary. It now separates the two cases the old blanketisEncryptedcheck lumped together:extractPages, which drops the encryption dictionary without needing owner access, and normalization continues. This is the approach verified in the issue;PDF.mergeandremoveProtection()were ruled out there already.The rebuild does not carry the AcroForm over, so case 1 is gated on
shouldFlattenForm. TodayflattenForm: falseis only the TEMPLATE path (create-envelope-items), so every signing path gets the fix and templates keep refusing rather than silently losing fields. If #2853 lands and a path stops flattening, that gate should follow it.Also switched
pdfDocfromconsttoletfor the reassignment.Verification
I reproduced the whole thing locally against
@libpdf/core0.4.2 (the version pinned inpackage.json) with qpdf-built fixtures:isEncrypted=true,isAuthenticated=true, rebuild produces a file that reloads withisEncrypted=false, page content intact.flattenForm: false: throws the new "would discard its form fields" message.PDF.loaditself throws before my branch is reached, so it keeps the existing "not a valid PDF" error. TheisAuthenticatedbackstop is there for paths and versions where load succeeds unauthenticated, which the issue observed on 0.4.0.One follow-up worth tracking, noticed while testing: for a genuinely locked file, libpdf 0.4.2 surfaces a misleading parse error ("Root Pages object is not a dictionary") rather than anything password-related, so the load-failure catch cannot reliably tell corruption from a password prompt. That is a
@libpdf/coreissue more than a Documenso one.