mirror of
https://github.com/AlistGo/alist.git
synced 2025-11-25 11:29:45 +08:00
refactor(webdav): Use ResolvePath instead of JoinPath (#9344)
- Changed the path concatenation method between `reqPath` and `src` and `dst` to use `ResolvePath` - Updated the implementation of path handling in multiple functions - Improved the consistency and reliability of path resolution
This commit is contained in:
22
server/webdav/path.go
Normal file
22
server/webdav/path.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package webdav
|
||||
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
)
|
||||
|
||||
// ResolvePath normalizes the provided raw path and resolves it against the user's base path
|
||||
// before delegating to the user-aware JoinPath permission checks.
|
||||
func ResolvePath(user *model.User, raw string) (string, error) {
|
||||
cleaned := utils.FixAndCleanPath(raw)
|
||||
basePath := utils.FixAndCleanPath(user.BasePath)
|
||||
|
||||
if cleaned != "/" && basePath != "/" && !utils.IsSubPath(basePath, cleaned) {
|
||||
cleaned = path.Join(basePath, strings.TrimPrefix(cleaned, "/"))
|
||||
}
|
||||
|
||||
return user.JoinPath(cleaned)
|
||||
}
|
||||
Reference in New Issue
Block a user