From 3ed042db7143ab6b54f128d20935ee0f604125a1 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 3 Feb 2021 15:25:12 +0100 Subject: [PATCH 1/2] fix unescape --- client.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/client.go b/client.go index 1c6306e..d96ad87 100644 --- a/client.go +++ b/client.go @@ -5,9 +5,7 @@ import ( "encoding/xml" "io" "net/http" - "net/url" "os" - pathpkg "path" "strings" "sync" "time" @@ -138,11 +136,9 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error) { if p := getProps(r, "200"); p != nil { f := new(File) - if ps, err := url.QueryUnescape(r.Href); err == nil { - f.name = pathpkg.Base(ps) - } else { - f.name = p.Name - } + + f.name = p.Name + f.path = path + f.name f.modified = parseModified(&p.Modified) f.etag = p.ETag From d02a1ebcd202b79ca13f90eac4600562aef1c1ef Mon Sep 17 00:00:00 2001 From: Nick Kratzke Date: Wed, 3 Feb 2021 21:16:30 +0100 Subject: [PATCH 2/2] switched to PathUnescape --- client.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index d96ad87..6539c45 100644 --- a/client.go +++ b/client.go @@ -5,7 +5,9 @@ import ( "encoding/xml" "io" "net/http" + "net/url" "os" + pathpkg "path" "strings" "sync" "time" @@ -136,9 +138,11 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error) { if p := getProps(r, "200"); p != nil { f := new(File) - - f.name = p.Name - + if ps, err := url.PathUnescape(r.Href); err == nil { + f.name = pathpkg.Base(ps) + } else { + f.name = p.Name + } f.path = path + f.name f.modified = parseModified(&p.Modified) f.etag = p.ETag