(raw string)
| 777 | } |
| 778 | |
| 779 | func normalizeSandboxRelativePath(raw string) (string, error) { |
| 780 | trimmed := strings.TrimSpace(raw) |
| 781 | if trimmed == "" { |
| 782 | return "", nil |
| 783 | } |
| 784 | normalized := strings.TrimLeft(trimmed, "/") |
| 785 | normalized = strings.TrimPrefix(normalized, "./") |
| 786 | if normalized == "" { |
| 787 | return ".", nil |
| 788 | } |
| 789 | normalized = filepath.ToSlash(filepath.Clean(normalized)) |
| 790 | if normalized == "" || normalized == "." { |
| 791 | return ".", nil |
| 792 | } |
| 793 | if strings.HasPrefix(normalized, "../") || normalized == ".." { |
| 794 | return "", fmt.Errorf("path must be relative to the sandbox workspace: %s", raw) |
| 795 | } |
| 796 | return normalized, nil |
| 797 | } |
| 798 | |
| 799 | func normalizeSandboxWorkspacePath(fileName string) (string, error) { |
| 800 | normalized, err := normalizeSandboxRelativePath(fileName) |
no test coverage detected