Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

local: clean absolute paths - fixes #6493

albertonyf4a571786cee
diff --git a/backend/local/local.go b/backend/local/local.go
index 7d56d8012..654bb02d1 100644
--- a/backend/local/local.go
+++ b/backend/local/local.go
@@ -1400,30 +1400,27 @@ func (o *Object) writeMetadata(metadata fs.Metadata) (err error) {
}
func cleanRootPath(s string, noUNC bool, enc encoder.MultiEncoder) string {
- if runtime.GOOS == "windows" {
- if !filepath.IsAbs(s) && !strings.HasPrefix(s, "\\") {
+ if runtime.GOOS != "windows" || !strings.HasPrefix(s, "\\") {
+ if !filepath.IsAbs(s) {
s2, err := filepath.Abs(s)
if err == nil {
s = s2
}
+ } else {
+ s = filepath.Clean(s)
}
+ }
+ if runtime.GOOS == "windows" {
s = filepath.ToSlash(s)
vol := filepath.VolumeName(s)
s = vol + enc.FromStandardPath(s[len(vol):])
s = filepath.FromSlash(s)
-
if !noUNC {
// Convert to UNC
s = file.UNCPath(s)
}
return s
}
- if !filepath.IsAbs(s) {
- s2, err := filepath.Abs(s)
- if err == nil {
- s = s2
- }
- }
s = enc.FromStandardPath(s)
return s
}