[Pkg-owncloud-commits] [owncloud] 49/83: Add trailing slash in FTP root path when missing

David Prévot taffit at moszumanska.debian.org
Wed Dec 18 13:05:30 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch 5.0
in repository owncloud.

commit 7c623053dc82f4136eeeb8992236895d34b2ff0e
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Thu Nov 28 11:45:26 2013 +0100

    Add trailing slash in FTP root path when missing
    
    Fixes #6093
    
    Backport of 84f3dd15a63fb80f33e61f6056e142b0443329d5
---
 apps/files_external/lib/ftp.php   |  3 +++
 apps/files_external/tests/ftp.php | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php
index 85d7a5a..00bf7a1 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 e146725..f994991 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_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'));
 	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list