nextcloud/server
View on GitHub[Bug]: Improper input validation in PublicPreviewController triggers internal server error
Open
#59229 opened on Mar 26, 2026
0. Needs triage32-feedbackbugfeature: previews and thumbnailsfeature: sharinggood first issue
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
An incomplete input validation in PublicPreviewController can trigger an internal server error.
Steps to reproduce
Case A
- Create a public link for a folder
- Send
GET https://server33.internal/index.php/apps/files_sharing/publicpreview/{token} - 💥
- Default for
$fileis an empty string. $file = $node->get('');is still an Folder instance- getPreview expectes File
Case B
- Create a public link for a folder
- Send
GET https://server33.internal/index.php/apps/files_sharing/publicpreview/{token}?file=notexist.png&mimeFallback=1 - 💥
getandgetPreviewboth throw NotFoundException.- However the branch with mimetype fallback only works if the preview not exists, not if the node not exists.
Expected behavior
No internal server error