(basePath, reqPath string)
| 75 | } |
| 76 | |
| 77 | func JoinBasePath(basePath, reqPath string) (string, error) { |
| 78 | /** relative path: |
| 79 | * 1. .. |
| 80 | * 2. ../ |
| 81 | * 3. /.. |
| 82 | * 4. /../ |
| 83 | * 5. /a/b/.. |
| 84 | */ |
| 85 | if reqPath == ".." || |
| 86 | strings.HasSuffix(reqPath, "/..") || |
| 87 | strings.HasPrefix(reqPath, "../") || |
| 88 | strings.Contains(reqPath, "/../") { |
| 89 | return "", errs.RelativePath |
| 90 | } |
| 91 | |
| 92 | reqPath = FixAndCleanPath(reqPath) |
| 93 | |
| 94 | if strings.HasPrefix(reqPath, "/") { |
| 95 | return reqPath, nil |
| 96 | } |
| 97 | |
| 98 | return stdpath.Join(FixAndCleanPath(basePath), FixAndCleanPath(reqPath)), nil |
| 99 | } |
| 100 | |
| 101 | func GetFullPath(mountPath, path string) string { |
| 102 | return stdpath.Join(GetActualMountPath(mountPath), path) |
no test coverage detected