ftpd: return relative paths for NLST reponses

Fixes #993

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-09-17 16:47:29 +02:00
parent cb98f8fd6d
commit b65fc0bdc2
5 changed files with 105 additions and 54 deletions

View File

@@ -300,7 +300,9 @@ func (c *Connection) ReadDir(name string) ([]os.FileInfo, error) {
// we only support wildcards for the last path level, for example:
// - *.xml is supported
// - dir*/*.xml is not supported
return c.getListDirWithWildcards(path.Dir(name), baseName)
name = path.Dir(name)
c.clientContext.SetListPath(name)
return c.getListDirWithWildcards(name, baseName)
}
return c.ListDir(name)
@@ -510,7 +512,10 @@ func (c *Connection) getListDirWithWildcards(dirName, pattern string) ([]os.File
return files, err
}
validIdx := 0
relativeBase := getPathRelativeTo(c.clientContext.Path(), dirName)
var relativeBase string
if c.clientContext.GetLastCommand() != "NLST" {
relativeBase = getPathRelativeTo(c.clientContext.Path(), dirName)
}
for _, fi := range files {
match, err := path.Match(pattern, fi.Name())
if err != nil {