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

config: stop config create making invalid config files

Nick Craig-Wood27eb8c7f4580
diff --git a/fs/config/config.go b/fs/config/config.go
index b2a354037..145f2a2df 100644
--- a/fs/config/config.go
+++ b/fs/config/config.go
@@ -475,6 +475,9 @@ func updateRemote(ctx context.Context, name string, keyValues rc.Params, opt Upd
// Set the config
for k, v := range keyValues {
vStr := fmt.Sprint(v)
+ if strings.ContainsAny(k, "\n\r") || strings.ContainsAny(vStr, "\n\r") {
+ return nil, fmt.Errorf("update remote: invalid key or value contains \\n or \\r")
+ }
// Obscure parameter if necessary
if _, ok := needsObscure[k]; ok {
_, err := obscure.Reveal(vStr)
@@ -483,7 +486,7 @@ func updateRemote(ctx context.Context, name string, keyValues rc.Params, opt Upd
// or we are forced to obscure
vStr, err = obscure.Obscure(vStr)
if err != nil {
- return nil, fmt.Errorf("UpdateRemote: obscure failed: %w", err)
+ return nil, fmt.Errorf("update remote: obscure failed: %w", err)
}
}
}