ResolvePath normalizes the provided raw path and resolves it against the user's base path before delegating to the user-aware JoinPath permission checks.
(user *model.User, raw string)
| 11 | // ResolvePath normalizes the provided raw path and resolves it against the user's base path |
| 12 | // before delegating to the user-aware JoinPath permission checks. |
| 13 | func ResolvePath(user *model.User, raw string) (string, error) { |
| 14 | cleaned := utils.FixAndCleanPath(raw) |
| 15 | basePath := utils.FixAndCleanPath(user.BasePath) |
| 16 | |
| 17 | if cleaned != "/" && basePath != "/" && !utils.IsSubPath(basePath, cleaned) { |
| 18 | cleaned = path.Join(basePath, strings.TrimPrefix(cleaned, "/")) |
| 19 | } |
| 20 | |
| 21 | return user.JoinPath(cleaned) |
| 22 | } |
no test coverage detected