Skip to content

fix(sharing): fix public share viewing and password-protected shares - #362

Merged
AndyScherzinger merged 1 commit into
mainfrom
fix/public-share-viewing
Sep 22, 2026
Merged

AndyScherzinger merged 1 commit into
mainfrom
fix/public-share-viewing

Conversation

@solracsf

Copy link
Copy Markdown
Member

Public share pages moved the isPublic/sharingToken/mimetype flags from hidden DOM inputs to initial state a while ago. This app still read the old inputs, so every public share (single file, folder, password-protected) fell through to the authenticated endpoints and failed to load or save. Switched to isPublicShare()/getSharingToken() from @nextcloud/sharing/public, already used elsewhere in the same file.

The iframe's error paths also called a FilesMindMap.hide() method that no longer exists since the app moved to the Viewer API; replaced with OCA.Viewer.close().

On the backend, a password-protected share was always rejected: the session key public_link_authenticated holds an array of authenticated share IDs (still populated by files_sharing's ShareController for exactly this purpose), but the check compared it against a single ID and could never match.

Adds a PHPUnit setup for the app (tests/, run from inside a server checkout), extending the one added in #355.

Tested locally on PHP 8.2 against stable33 and stable34, MariaDB 11.8 and PostgreSQL 16: the new PHPUnit tests fail on the old code and pass with the fix. Confirmed in a real browser against both versions that a single-file share, a folder share, and a password-protected share all now open and edit correctly; reproduced the original failures against the pre-fix build for comparison. npm run lint, npm run test and npm run build all pass.

The public load/save flow read #isPublic, #sharingToken and #mimetype
hidden inputs to detect a public share page. Those inputs were removed
when the files_sharing public page moved to initial state, so a public
share always fell through to the authenticated endpoints and failed.
Detect the public share the same way the rest of the app already does,
via isPublicShare()/getSharingToken() from @nextcloud/sharing/public.

The iframe's error paths also called FilesMindMap.hide(), a method that
no longer exists since the app moved to the Viewer API. Call the
Viewer's own OCA.Viewer.close() instead.

On the backend, a password-protected share was always rejected: the
session stores an array of authenticated share IDs
(public_link_authenticated, still filled by files_sharing's
ShareController for this exact purpose), but the check compared it
directly against a single share ID and could never match.

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf solracsf added bug Something isn't working 3. to review labels Sep 22, 2026
@solracsf solracsf self-assigned this Sep 22, 2026
@AndyScherzinger
AndyScherzinger merged commit c844636 into main Sep 22, 2026
8 checks passed
@AndyScherzinger
AndyScherzinger deleted the fix/public-share-viewing branch September 22, 2026 21:21
@AndyScherzinger AndyScherzinger added this to the v0.1.3 milestone Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants