summaryrefslogtreecommitdiffstats
path: root/tests/lib/files/filesystem.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-01-10 17:35:40 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-01-10 17:35:40 +0100
commitc91d47e5b3ad8b2b6d30f7f4fdeff1a1d7e744a5 (patch)
treeb53758a37f09c65a40f023dc4655203bf8df2d11 /tests/lib/files/filesystem.php
parentc259733b881138c273b4af18d788f3df53497871 (diff)
parent05615bfd473f1eafa4ec253779568ab044467ceb (diff)
downloadnextcloud-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.php33
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:\\'),