diff --git a/onedrive/onedrive.go b/onedrive/onedrive.go index 1942948ac..adc27a6a5 100644 --- a/onedrive/onedrive.go +++ b/onedrive/onedrive.go @@ -8,6 +8,7 @@ import ( "io" "log" "net/http" + "net/url" "regexp" "strings" "time" @@ -145,7 +146,7 @@ func shouldRetry(resp *http.Response, err error) (bool, error) { func (f *Fs) readMetaDataForPath(path string) (info *api.Item, resp *http.Response, err error) { opts := rest.Opts{ Method: "GET", - Path: "/drive/root:/" + replaceReservedChars(path), + Path: "/drive/root:/" + url.QueryEscape(replaceReservedChars(path)), } err = f.pacer.Call(func() (bool, error) { resp, err = f.srv.CallJSON(&opts, nil, &info) @@ -738,7 +739,7 @@ func (o *Object) ModTime() time.Time { func (o *Object) setModTime(modTime time.Time) (*api.Item, error) { opts := rest.Opts{ Method: "PATCH", - Path: "/drive/root:/" + o.srvPath(), + Path: "/drive/root:/" + url.QueryEscape(o.srvPath()), } update := api.SetFileSystemInfo{ FileSystemInfo: api.FileSystemInfoFacet{ @@ -793,7 +794,7 @@ func (o *Object) Open() (in io.ReadCloser, err error) { func (o *Object) createUploadSession() (response *api.CreateUploadResponse, err error) { opts := rest.Opts{ Method: "POST", - Path: "/drive/root:/" + o.srvPath() + ":/upload.createSession", + Path: "/drive/root:/" + url.QueryEscape(o.srvPath()) + ":/upload.createSession", } var resp *http.Response err = o.fs.pacer.Call(func() (bool, error) { @@ -903,7 +904,7 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo) (err error) { var resp *http.Response opts := rest.Opts{ Method: "PUT", - Path: "/drive/root:/" + o.srvPath() + ":/content", + Path: "/drive/root:/" + url.QueryEscape(o.srvPath()) + ":/content", Body: in, } err = o.fs.pacer.CallNoRetry(func() (bool, error) {