-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Add support for AuthEvent
#20732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add support for AuthEvent
#20732
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ class XRef { | |
| this._newPersistentRefNum = null; | ||
| this._newTemporaryRefNum = null; | ||
| this._persistentRefsCache = null; | ||
| this.decryptOnAttachmentOpen = false; | ||
| } | ||
|
|
||
| getNewPersistentRef(obj) { | ||
|
|
@@ -117,18 +118,26 @@ class XRef { | |
| warn(`XRef.parse - Invalid "Encrypt" reference: "${ex}".`); | ||
| } | ||
| if (encrypt instanceof Dict) { | ||
| const ids = trailerDict.get("ID"); | ||
| const fileId = ids?.length ? ids[0] : ""; | ||
| // The 'Encrypt' dictionary itself should not be encrypted, and by | ||
| // setting `suppressEncryption` we can prevent an infinite loop inside | ||
| // of `XRef_fetchUncompressed` if the dictionary contains indirect | ||
| // objects (fixes issue7665.pdf). | ||
| encrypt.suppressEncryption = true; | ||
| this.encrypt = new CipherTransformFactory( | ||
| encrypt, | ||
| fileId, | ||
| this.pdfManager.password | ||
| ); | ||
| // Note: decrypting attachments is not supported regardless. | ||
| // But it is at least possible to honour `/AuthEvent /EFOpen` by not | ||
| // asking for a password on document open. | ||
| this.decryptOnAttachmentOpen = | ||
| encrypt.get("CF")?.get("StdCF")?.get("AuthEvent")?.name === "EFOpen"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So here you're reading the encrypt dict without setting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You completely ignore the EFF value, right ? Is it a good idea ? |
||
|
|
||
| if (!this.decryptOnAttachmentOpen) { | ||
| const ids = trailerDict.get("ID"); | ||
| const fileId = ids?.length ? ids[0] : ""; | ||
| // The 'Encrypt' dictionary itself should not be encrypted, and by | ||
| // setting `suppressEncryption` we can prevent an infinite loop inside | ||
| // of `XRef_fetchUncompressed` if the dictionary contains indirect | ||
| // objects (fixes issue7665.pdf). | ||
| encrypt.suppressEncryption = true; | ||
| this.encrypt = new CipherTransformFactory( | ||
| encrypt, | ||
| fileId, | ||
| this.pdfManager.password | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // Get the root dictionary (catalog) object, and do some basic validation. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we
console.warnsomething like "there are encrypted attachments but they are not supported yet"?Also, question about the PDF format: is it possible to have some encrypted attachments and some not? In this case we should probably still show the non-encrypted ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the last 2 blockquotes from #20139 (comment).
As I understand it, pdf generators should make PDFs with all attachments encrypted.
There is also the case of encrypted attachments w/o
AuthEvent.I considered looking into it, indeed having a nice warning, but I think it’s better to spend that time into actually solving the issue #20139.
So this also relates to
console.warn: this PR does not change encrypted attachment handling. Those are not detected and yield warnings already. This only honors when to ask for a password.