fix(files_sharing): validate input in PublicPreviewController#getPreview#59253
Open
mvanhorn wants to merge 2 commits intonextcloud:masterfrom
Open
fix(files_sharing): validate input in PublicPreviewController#getPreview#59253mvanhorn wants to merge 2 commits intonextcloud:masterfrom
mvanhorn wants to merge 2 commits intonextcloud:masterfrom
Conversation
Return 400 Bad Request when the file parameter is empty and the shared node is a folder, instead of passing the folder itself to getPreview which triggers an internal server error. Also rename the local variable to $fileNode to prevent the catch block from calling getMimeType() on the original string parameter when get() throws NotFoundException. Fixes nextcloud#59229 Signed-off-by: Matt Van Horn <[email protected]> Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Josh <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two cases where
PublicPreviewController::getPreview()triggers aninternal server error due to incomplete input validation:
Case A - Empty
$fileparameter on folder shares:$node->get('')returns the Folder itself, thengetPreview()fails becauseit expects a File. Now returns 400 Bad Request early.
Case B - Non-existent file with
mimeFallback=1:When
$node->get($file)throwsNotFoundException, the catch block called$file->getMimeType()on the original string parameter. Renamed the localvariable to
$fileNodeand added anisset()guard so the mime fallbackonly runs when the file node was successfully resolved.
Fixes #59229