diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-01-10 17:35:40 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-01-10 17:35:40 +0100 |
commit | c91d47e5b3ad8b2b6d30f7f4fdeff1a1d7e744a5 (patch) | |
tree | b53758a37f09c65a40f023dc4655203bf8df2d11 /tests/lib/files/filesystem.php | |
parent | c259733b881138c273b4af18d788f3df53497871 (diff) | |
parent | 05615bfd473f1eafa4ec253779568ab044467ceb (diff) | |
download | nextcloud-server-c91d47e5b3ad8b2b6d30f7f4fdeff1a1d7e744a5.tar.gz nextcloud-server-c91d47e5b3ad8b2b6d30f7f4fdeff1a1d7e744a5.zip |
Merge pull request #13224 from owncloud/simplify-is-valid-path-and-add-unit-tests
Simplify isValidPath and add unit tests
Diffstat (limited to 'tests/lib/files/filesystem.php')
-rw-r--r-- | tests/lib/files/filesystem.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index 1b84db0fc0d..888690adb0e 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -154,6 +154,39 @@ class Filesystem extends \Test\TestCase { $this->assertEquals($expected, \OC\Files\Filesystem::normalizePath($path, $stripTrailingSlash)); } + public function isValidPathData() { + return array( + array('/', true), + array('/path', true), + array('/foo/bar', true), + array('/foo//bar/', true), + array('/foo////bar', true), + array('/foo//\///bar', true), + array('/foo/bar/.', true), + array('/foo/bar/./', true), + array('/foo/bar/./.', true), + array('/foo/bar/././', true), + array('/foo/bar/././..bar', true), + array('/foo/bar/././..bar/a', true), + array('/foo/bar/././..', false), + array('/foo/bar/././../', false), + array('/foo/bar/.././', false), + array('/foo/bar/../../', false), + array('/foo/bar/../..\\', false), + array('..', false), + array('../', false), + array('../foo/bar', false), + array('..\foo/bar', false), + ); + } + + /** + * @dataProvider isValidPathData + */ + public function testIsValidPath($path, $expected) { + $this->assertSame($expected, \OC\Files\Filesystem::isValidPath($path)); + } + public function normalizePathWindowsAbsolutePathData() { return array( array('C:/', 'C:\\'), |