diff options
Diffstat (limited to 'hotline/file_path.go')
| -rw-r--r-- | hotline/file_path.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/hotline/file_path.go b/hotline/file_path.go index a3a13f1..c97faea 100644 --- a/hotline/file_path.go +++ b/hotline/file_path.go @@ -115,14 +115,22 @@ func ReadPath(fileRoot string, filePath, fileName []byte) (fullPath string, err subPath = path.Join("/", subPath, string(pathItem.Name)) } + // Decode only client-provided path components from Mac Roman to UTF-8. + // The fileRoot is already a UTF-8 filesystem path and must not be decoded. + subPath, err = txtDecoder.String(subPath) + if err != nil { + return "", fmt.Errorf("invalid filepath encoding: %w", err) + } + + decodedFileName, err := txtDecoder.String(string(fileName)) + if err != nil { + return "", fmt.Errorf("invalid filename encoding: %w", err) + } + fullPath = path.Join( fileRoot, subPath, - path.Join("/", string(fileName)), + path.Join("/", decodedFileName), ) - fullPath, err = txtDecoder.String(fullPath) - if err != nil { - return "", fmt.Errorf("invalid filepath encoding: %w", err) - } return fullPath, nil } |