Skip to content

Add support for encrypted attachments#21234

Merged
calixteman merged 1 commit into
mozilla:masterfrom
wooorm:wooorm/encrypted-attachments
May 28, 2026
Merged

Add support for encrypted attachments#21234
calixteman merged 1 commit into
mozilla:masterfrom
wooorm:wooorm/encrypted-attachments

Conversation

@wooorm

@wooorm wooorm commented May 7, 2026

Copy link
Copy Markdown
Collaborator

This PR is related to GH-20732, which is about AuthEvent (to delay promting for a password), but instead adds the actual support for encrypted attachments.
“Encrypted attachments” means that the main things are plain text. Note that some PDF viewers, like Preview/QuickLook/Safari or Chrome, do not support attachments at all.
Also note that the file checked into the tests is the same as output-no-auth-event.pdf referenced in
#20139 (comment).

Closes GH-20139.

@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 7, 2026 11:42 — with GitHub Actions Inactive
@codecov-commenter

codecov-commenter commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.41%. Comparing base (b849567) to head (45cdb5d).

Files with missing lines Patch % Lines
src/core/parser.js 87.50% 3 Missing ⚠️
src/core/crypto.js 93.54% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21234      +/-   ##
==========================================
- Coverage   81.42%   81.41%   -0.02%     
==========================================
  Files         257      257              
  Lines       65351    65368      +17     
==========================================
+ Hits        53212    53219       +7     
- Misses      12139    12149      +10     
Flag Coverage Δ
fonttest 9.10% <0.00%> (-0.01%) ⬇️
integrationtest 66.98% <67.27%> (-0.02%) ⬇️
unittest 56.88% <90.90%> (-0.01%) ⬇️
unittestcli 56.09% <90.90%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wooorm wooorm force-pushed the wooorm/encrypted-attachments branch from a618a1f to 64ecd4c Compare May 13, 2026 13:27
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 13, 2026 13:27 — with GitHub Actions Inactive
Comment thread src/core/parser.js Outdated
Comment thread src/core/parser.js Outdated
@wooorm wooorm force-pushed the wooorm/encrypted-attachments branch from 64ecd4c to 2faecb8 Compare May 19, 2026 08:48
@wooorm wooorm temporarily deployed to code-coverage May 19, 2026 08:48 — with GitHub Actions Inactive
Comment thread src/core/crypto.js Outdated
Comment thread src/core/crypto.js Outdated
Comment thread src/core/crypto.js Outdated
Comment thread src/core/parser.js Outdated
This PR is related to mozillaGH-20732, which is about `AuthEvent` (to delay
promting for a password), but instead adds the actual support for
encrypted attachments.
“Encrypted attachments” means that the main things are plain text.
Note that some PDF viewers, like Preview/QuickLook/Safari or Chrome,
do not support attachments at all.
Note that the file checked into the tests is the same as
`output-no-auth-event.pdf` referenced in
<mozilla#20139 (comment)>.

Closes mozillaGH-20139.
@wooorm wooorm force-pushed the wooorm/encrypted-attachments branch from 2faecb8 to 45cdb5d Compare May 28, 2026 08:30
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 08:30 — with GitHub Actions Inactive
@wooorm

wooorm commented May 28, 2026

Copy link
Copy Markdown
Collaborator Author

nits applied, rebased, and squashed!

@calixteman

Copy link
Copy Markdown
Contributor

/botio-linux browsertest

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_browsertest from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/3b2e75b8a0763a8/output.txt

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/3b2e75b8a0763a8/output.txt

Total script time: 18.25 mins

  • Regression tests: Passed

@calixteman calixteman merged commit 974f986 into mozilla:master May 28, 2026
22 checks passed
wooorm added a commit to wooorm/pdf.js that referenced this pull request Jun 1, 2026
Normally entire PDFs are encrypted (or not).
But it is also possible to only encrypt attachments.
It is then also possible to *only* prompt for a password when the user opens
them.

In the existing flow, prompting for passwords happens because things are decrypted.
A specific error is thrown, caught, and the user is prompted.
To keep this flow working, this PR changes to decrypting attachments on demand,
instead of eagerly.
This sounds logical: to not read attachments on startup.

I’ve extensively tested this, not only with regular attachments, but also with outline items
and attachments in annotations.

This PR builds on mozillaGH-21234.
It’s an alternative to the naïve mozillaGH-20732.

Closes mozillaGH-20049.
wooorm added a commit to wooorm/pdf.js that referenced this pull request Jun 3, 2026
Normally entire PDFs are encrypted (or not).
But it is also possible to only encrypt attachments.
It is then also possible to *only* prompt for a password when the user opens
them.

In the existing flow, prompting for passwords happens because things are decrypted.
A specific error is thrown, caught, and the user is prompted.
To keep this flow working, this PR changes to decrypting attachments on demand,
instead of eagerly.
This sounds logical: to not read attachments on startup.

I’ve extensively tested this, not only with regular attachments, but also with outline items
and attachments in annotations.

This PR builds on mozillaGH-21234.
It’s an alternative to the naïve mozillaGH-20732.

Closes mozillaGH-20049.
wooorm added a commit to wooorm/pdf.js that referenced this pull request Jun 3, 2026
Normally entire PDFs are encrypted (or not).
But it is also possible to only encrypt attachments.
It is then also possible to *only* prompt for a password when the user opens
them.

In the existing flow, prompting for passwords happens because things are decrypted.
A specific error is thrown, caught, and the user is prompted.
To keep this flow working, this PR changes to decrypting attachments on demand,
instead of eagerly.
This sounds logical: to not read attachments on startup.

I’ve extensively tested this, not only with regular attachments, but also with outline items
and attachments in annotations.

This PR builds on mozillaGH-21234.
It’s an alternative to the naïve mozillaGH-20732.

Closes mozillaGH-20049.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: File Attachments do not open when they are encrypted

6 participants