Compare commits

..

No commits in common. "main" and "v1.5.2" have entirely different histories.
main ... v1.5.2

View File

@ -308,9 +308,9 @@ func VerifyPathForSafeMode(ctx context.Context, path string) (string, error) {
return RealPath(path), nil return RealPath(path), nil
} }
// 1. 获取白名单 // 1. 获取白名单 (约定从 ctx 获取 "AllowedDirs")
var allowedDirs []string var allowedDirs []string
cast.Convert(&allowedDirs, jsmod.Get(ctx, "AllowedDirs")) cast.Convert(&allowedDirs, ctx.Value("AllowedDirs"))
if len(allowedDirs) == 0 { if len(allowedDirs) == 0 {
return "", fmt.Errorf("file: access denied, AllowedDirs not found in context") return "", fmt.Errorf("file: access denied, AllowedDirs not found in context")
} }