fspath: Implement a connection string parser #4996

This is implemented as a state machine parser so it can emit sensible
error messages.

It does not use the connection strings elsewhere in rclone yet - see
subsequent commits.

An optional fuzzer is implemented for the Parse function.
This commit is contained in:
Nick Craig-Wood
2021-02-09 09:30:40 +00:00
parent 3b21857097
commit 8a46dd1b57
8 changed files with 613 additions and 70 deletions

View File

@ -277,10 +277,11 @@ func NewFs(ctx context.Context, name, rpath string, m configmap.Mapper) (fs.Fs,
return nil, errors.New("can't point remote at itself - check the value of the remote setting")
}
baseName, basePath, err := fspath.Parse(remote)
parsed, err := fspath.Parse(remote)
if err != nil {
return nil, errors.Wrapf(err, "failed to parse remote %q to wrap", remote)
}
baseName, basePath := parsed.ConfigString, parsed.Path
if baseName != "" {
baseName += ":"
}