fix(files_sharing): validate empty file parameter in PublicPreviewController#59460
fix(files_sharing): validate empty file parameter in PublicPreviewController#59460psimaker wants to merge 1 commit intonextcloud:masterfrom
Conversation
PublicPreviewController Fixes nextcloud#59229 - Return 400 Bad Request when file parameter is empty for folder shares - Separate node resolution from preview generation to prevent crash when mimeFallback is used with non-existent files Signed-off-by: Umo <umut.erdem@protonmail.com> Signed-off-by: Umo <umut.erdem@protonmail.com>
|
Thanks but this is duplicate ongoing #59253 |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Fixes #59229
Summary
The
getPreview()method inPublicPreviewControllerhad two input validation issuesthat caused internal server errors:
Case A: When requesting a public preview for a folder share without a
fileparameter,$node->get('')returns the Folder itself.getPreview()then crashes because it expectsa
Fileinstance, not aFolder.Case B: When requesting a non-existent file with
mimeFallback=true, theNotFoundExceptionfrom
$node->get($file)falls into the catch block where$file->getMimeType()is called.At that point
$fileis still the original string parameter, not a Node object, causing afatal error.
Changes
400 Bad Requestwhen$fileis empty on folder shares$fileis always a valid Node object whenmimeFallbackcode executesTest plan
testPreviewFolderEmptyFile— empty file parameter returns 400testPreviewFolderInvalidFileWithMimeFallback— non-existent file with mimeFallback returns 404testPreviewFolderValidFileNoPreviewWithMimeFallback— valid file, no preview, mimeFallback redirects to mime icon