Add trailing slash in FTP root path when missing

Fixes #6093
This commit is contained in:
Vincent Petry 2013-11-28 11:45:26 +01:00
parent f23d641b82
commit 84f3dd15a6
2 changed files with 15 additions and 0 deletions

View File

@ -35,6 +35,9 @@ class FTP extends \OC\Files\Storage\StreamWrapper{
if ( ! $this->root || $this->root[0]!='/') {
$this->root='/'.$this->root;
}
if (substr($this->root, -1) !== '/') {
$this->root .= '/';
}
} else {
throw new \Exception();
}

View File

@ -48,5 +48,17 @@ class FTP extends Storage {
$config['secure'] = 'true';
$instance = new \OC\Files\Storage\FTP($config);
$this->assertEquals('ftps://ftp:ftp@localhost/', $instance->constructUrl(''));
$config['root'] = '';
$instance = new \OC\Files\Storage\FTP($config);
$this->assertEquals('ftps://ftp:ftp@localhost/somefile.txt', $instance->constructUrl('somefile.txt'));
$config['root'] = '/abc';
$instance = new \OC\Files\Storage\FTP($config);
$this->assertEquals('ftps://ftp:ftp@localhost/abc/somefile.txt', $instance->constructUrl('somefile.txt'));
$config['root'] = '/abc/';
$instance = new \OC\Files\Storage\FTP($config);
$this->assertEquals('ftps://ftp:ftp@localhost/abc/somefile.txt', $instance->constructUrl('somefile.txt'));
}
}