fix for caddy web server

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
This commit is contained in:
Vasiliy Tolstov 2017-04-26 11:02:30 +03:00 committed by Nick Craig-Wood
parent d5d635b7f3
commit 83b642e98f

View File

@ -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,