🎨 Add file access control (#9722)

This commit is contained in:
Yingyi / 颖逸 2023-11-22 22:17:18 +08:00 committed by GitHub
parent f5205d846c
commit 4ca62ef701
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 139 additions and 65 deletions

View file

@ -265,3 +265,12 @@ func IsDisplayableAsset(p string) bool {
}
return false
}
func GetAbsPathInWorkspace(relPath string) (string, error) {
absPath := filepath.Join(WorkspaceDir, relPath)
if IsSubPath(WorkspaceDir, absPath) {
return absPath, nil
} else {
return "", os.ErrPermission
}
}