MCPcopy
hub / github.com/AlistGo/alist / JoinPath

Method JoinPath

internal/model/user.go:157–181  ·  view source on GitHub ↗
(reqPath string)

Source from the content-addressed store, hash-verified

155}
156
157func (u *User) JoinPath(reqPath string) (string, error) {
158 if reqPath == "/" {
159 return utils.FixAndCleanPath(u.BasePath), nil
160 }
161 path, err := utils.JoinBasePath(u.BasePath, reqPath)
162 if err != nil {
163 return "", err
164 }
165
166 if path != "/" && u.CheckPathLimit() {
167 basePaths := GetAllBasePathsFromRoles(u)
168 match := false
169 for _, base := range basePaths {
170 if utils.IsSubPath(base, path) {
171 match = true
172 break
173 }
174 }
175 if !match {
176 return "", errs.PermissionDenied
177 }
178 }
179
180 return path, nil
181}
182
183func StaticHash(password string) string {
184 return utils.HashData(utils.SHA256, []byte(fmt.Sprintf("%s-%s", password, StaticHashSalt)))

Callers 15

LinkMethod · 0.80
PutMethod · 0.80
postMethod · 0.80
AddFromLinkMethod · 0.80
FsUpFunction · 0.80
ResolvePathFunction · 0.80
handleFsUploadFunction · 0.80
handleFsMkdirFunction · 0.80
handleFsRenameFunction · 0.80
handleFsMoveFunction · 0.80
handleFsCopyFunction · 0.80
handleFsRemoveFunction · 0.80

Calls 5

CheckPathLimitMethod · 0.95
FixAndCleanPathFunction · 0.92
JoinBasePathFunction · 0.92
IsSubPathFunction · 0.92
GetAllBasePathsFromRolesFunction · 0.85

Tested by

no test coverage detected