summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <morris.jobke@gmail.com>2013-11-28 04:52:08 -0800
committerMorris Jobke <morris.jobke@gmail.com>2013-11-28 04:52:08 -0800
commit3a31f7eb4adf6cd2472d3912e5a3214e99767d8a (patch)
tree2ba195db764f11db1ee4534fe75bffb6be7d44c1 /apps
parent603613e6e632c72c993844b29faad4c1cd067b32 (diff)
parent84f3dd15a63fb80f33e61f6056e142b0443329d5 (diff)
downloadnextcloud-server-3a31f7eb4adf6cd2472d3912e5a3214e99767d8a.tar.gz
nextcloud-server-3a31f7eb4adf6cd2472d3912e5a3214e99767d8a.zip
Merge pull request #6097 from owncloud/extstorage-ftptrailingslash
Add trailing slash in FTP root path when missing
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/ftp.php3
-rw-r--r--apps/files_external/tests/ftp.php12
2 files changed, 15 insertions, 0 deletions
diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php
index ca6c635eb2b..1f3ebd14b39 100644
--- a/apps/files_external/lib/ftp.php
+++ b/apps/files_external/lib/ftp.php
@@ -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();
}
diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php
index 94ed5630d91..3037793120a 100644
--- a/apps/files_external/tests/ftp.php
+++ b/apps/files_external/tests/ftp.php
@@ -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'));
}
}