From 83b642e98ffccc1a2a0f023c40988356c741d3a9 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 26 Apr 2017 11:02:30 +0300 Subject: [PATCH] fix for caddy web server Signed-off-by: Vasiliy Tolstov --- http/http.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/http/http.go b/http/http.go index c7367b78c..7a67dcdad 100644 --- a/http/http.go +++ b/http/http.go @@ -217,9 +217,9 @@ func parseTime(n *html.Node) (t time.Time) { return t } -func (f *Fs) readDir(path string) ([]*entry, error) { +func (f *Fs) readDir(p string) ([]*entry, error) { entries := make([]*entry, 0) - res, err := f.httpClient.Get(urlJoin(f.endpoint, path)) + res, err := f.httpClient.Get(urlJoin(f.endpoint, p)) if err != nil { return nil, err } @@ -244,9 +244,17 @@ func (f *Fs) readDir(path string) ([]*entry, error) { if err != nil { continue } - if name == "../" || name == "./" { + if name == "../" || name == "./" || name == ".." { break } + if strings.Index(name, "?") >= 0 || strings.HasPrefix(name, "http") { + break + } + u, err := url.Parse(name) + if err != nil { + break + } + name = path.Clean(u.Path) e := &entry{ name: strings.TrimRight(name, "/"), url: name,