Skip to content

fix(handlers): offer encrypted files only to handlers that read them over dav - #38

Merged
skjnldsv merged 2 commits into
mainfrom
fix/encrypted-files-need-dav
Sep 16, 2026
Merged

skjnldsv merged 2 commits into
mainfrom
fix/encrypted-files-need-dav

Conversation

@skjnldsv

@skjnldsv skjnldsv commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

The old viewer app grew this after the library forked from it: nextcloud/viewer@5aeb510e limits end-to-end encrypted files to the image, video and audio mimes, because since Nextcloud 33 the e2ee app decrypts transparently, but only over WebDAV. A handler fetching through its own endpoint (Text, the PDF viewer) gets ciphertext. The library offered an encrypted file to any handler taking its mime.

Rather than a mime list in the core, the handler says so: supportsEndToEndEncryption?: boolean on IHandler, set on the three default handlers. isHandlerEnabled() refuses a set holding a file with the e2ee-is-encrypted dav attribute for a handler without the flag, before asking its enabled(). That one function is behind the file actions, canView(), getHandlerForFile() and the viewer's own handlerFor(), so all four agree.

Handlers that read the file from node.encodedSource can set the flag. It is additive, the default is the safe one, and the README table and example carry it.

__tests__/encryptedFiles.spec.ts: refused without asking enabled(), taken with the flag, one encrypted file taints a set, false or absent attribute changes nothing, canView and getHandlerForFile skip to the flagged handler, "Open with" entries follow, and the three defaults carry the flag. Not tested against a live e2ee setup.

👾 This pull request was assisted by Claude Code, commits carry an Assisted-by trailer.

…over dav

Since Nextcloud 33 the end-to-end encryption app decrypts files
transparently, but only on the WebDAV endpoint. A handler that fetches
the bytes through an endpoint of its own gets ciphertext, so the old
viewer app limited encrypted files to its image, video and audio
handlers by mime (nextcloud/viewer@5aeb510e). This library did not carry
that over and offered an encrypted file to every handler taking its mime.

A handler now opts in with supportsEndToEndEncryption, set on the three
default handlers, and a set holding an encrypted file is never shown to
a handler without it: not through the file actions, not through
canView(), and not by the viewer picking a handler for a file in the
list. The handler's own enabled() is not even asked.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
@skjnldsv skjnldsv added status: review Waiting for reviews type: bug 🐛 Something isn't working AI assisted labels Sep 12, 2026
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.86%. Comparing base (7735d90) to head (dd60fbd).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
+ Coverage   87.83%   87.86%   +0.03%     
==========================================
  Files          36       36              
  Lines        2474     2481       +7     
  Branches      519      521       +2     
==========================================
+ Hits         2173     2180       +7     
  Misses        297      297              
  Partials        4        4              

☔ View full report in Codecov by Harness.
📢 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.

@skjnldsv
skjnldsv requested a review from artonge September 12, 2026 15:53
@skjnldsv

Copy link
Copy Markdown
Contributor Author

@artonge does it make sense?

@artonge artonge left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefere that we support the other ways of fetching files, but that is not hapening anytime soon. So good enough for now :).

Comment thread lib/handlers.ts
Comment thread lib/handlers.ts Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Previews of end-to-end encrypted files are not a given, so the docs no
longer name them as a way to read one: the flag is about reading the
file from its dav source.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
@skjnldsv
skjnldsv merged commit 4dd366b into main Sep 16, 2026
18 checks passed
@skjnldsv
skjnldsv deleted the fix/encrypted-files-need-dav branch September 16, 2026 15:47
@skjnldsv skjnldsv mentioned this pull request Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted status: review Waiting for reviews type: bug 🐛 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants