]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add trailing slash in FTP root path when missing
authorVincent Petry <pvince81@owncloud.com>
Thu, 28 Nov 2013 10:45:26 +0000 (11:45 +0100)
committerVincent Petry <pvince81@owncloud.com>
Mon, 2 Dec 2013 11:02:40 +0000 (12:02 +0100)
Fixes #6093

Backport of 84f3dd15a63fb80f33e61f6056e142b0443329d5

apps/files_external/lib/ftp.php
apps/files_external/tests/ftp.php

index 85d7a5a32aee7134a1f8779315939199e0c82286..00bf7a189cebabba35e76880e8aec7b69edf8b6c 100644 (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();
                }
index e146725473ac2bfb3444090a03ebfde58db86836..f994991d59d09f3fd60a319ca965dde475e63744 100644 (file)
@@ -48,5 +48,17 @@ class FTP extends Storage {
                $config['secure'] = 'true';
                $instance = new OC_Filestorage_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'));
        }
 }