fix(http): canonicalize paths before checking access rules (#6045)

This commit is contained in:
Henrique Dias authored and GitHub committed 2026-07-26 10:00:18 +02:00
1 parent 41e2b1bbba
commit e6d70cf24c
15 files changed
+403 -31

No files matched your search

+7 -4
View File
@@ -52,14 +52,15 @@ var withHashFile = func(fn handleFunc) handleFunc {
return errToStatus(err), err
}
// share base path
basePath := link.Path
// share base path. Canonicalized because it roots both the rebased
// filesystem and checkerPrefix below, and a stored path that is not
// "/"-separated would make the two disagree on Windows.
basePath := slashClean(link.Path)
// file relative path
filePath := ""
if file.IsDir {
basePath = filepath.Clean(link.Path)
filePath = ifPath
}
@@ -109,7 +110,9 @@ func ifPathWithName(r *http.Request) (id, filePath string) {
case 1:
return r.URL.Path, "/"
default:
return pathElements[0], path.Join("/", path.Join(pathElements[1:]...))
// Public share routes do not pass through withUser, so canonicalize the
// share-relative path here instead.
return pathElements[0], slashClean(path.Join(pathElements[1:]...))
}
}