Repository navigation
fix(sharing): load mind maps from subfolders of public shares - #400
Merged
Merged
Conversation
The public load endpoint joined the folder and the file name without a separator, so a mind map in a subfolder of a public folder share was looked up as /Subfoldernotes.km and failed with "File not found". Join them with a slash, as the logged-in endpoint does. A path outside of the share made Folder::get() throw NotPermittedException, which ended in a server error; answer it with "File not found" too. Fixes #145 Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 task done
Saving to a path outside of a public folder share made Folder::get() throw NotPermittedException, which ended in a server error. Nothing was written, but answer it with "File not found" like the load endpoint. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
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.
Fixes #145
Opening a mind map from a subfolder of a public folder share showed "Load file fail!File not found", and closing the alert closed the viewer.
PublicFileHandlingController::load()built the path astrim($dir.$filename). The frontend sendsdiras the file's folder without a trailing slash (dirname()of its path), so/SubfolderandTest 2.kmbecame/SubfolderTest 2.km. At the share rootdiris/, which is why files there opened. The logged-in endpoint already joins with a slash, and saving was not affected because the frontend builds the save path itself.rtrim($dir, '/') . '/' . $filename), so the share root still resolves to/name.km.Folder::get()throwNotPermittedException. The controller only caughtNotFoundException, so such a request ended in a server error page. It now gets the same 404 "File not found". The public save endpoint had the same gap and gets the same fix. Nothing was ever written outside the share; it only answered with a server error.Testing:
Path traversal check, on Nextcloud 32, 35 and 36, with the owner's file next to the shared folder as the target:
dir:/../,../,..,/..,/Subfolder/../..,/./../,/%2e%2e/,/..\,/../../../../etcfilename:../x,..%2Fx,/../x,..\x,..,../../../../etc/passwddir./,/./,., empty or//load the file inside the share, becauseFolder::get()normalizes them. Any..is refused, even one that would stay inside (/Subfolder/..). Afilenameof.or/resolves to the shared folder itself and returns 400 ("not a file").A backport to
stable-0.1follows.🤖 AI (if applicable)