Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-11-14 16:15:03 +0400
committerVincent Petry <pvince81@owncloud.com>2013-11-15 13:39:43 +0400
commite44831d10f47e409623f2213488cac72915ffb69 (patch)
tree69bdec11e04616714590f2687b5b90c70ab29ae2 /tests
parent5aabf3826a6d58c8e30b6fd188d8357cc43135aa (diff)
Fixed normalizePath() to strip out single dot dirs
Now removing "/./" and trailing "/." from the paths when normalizing. Backport of c06d8bb0071839480f9e458e58630ca0c205b9cb
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/filesystem.php55
1 files changed, 54 insertions, 1 deletions
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php
index bef70cc725b..83e0d284822 100644
--- a/tests/lib/files/filesystem.php
+++ b/tests/lib/files/filesystem.php
@@ -66,17 +66,70 @@ class Filesystem extends \PHPUnit_Framework_TestCase {
}
public function testNormalize() {
+ $this->assertEquals('/', \OC\Files\Filesystem::normalizePath(''));
+ $this->assertEquals('/', \OC\Files\Filesystem::normalizePath('/'));
+ $this->assertEquals('/', \OC\Files\Filesystem::normalizePath('/', false));
+ $this->assertEquals('/', \OC\Files\Filesystem::normalizePath('//'));
+ $this->assertEquals('/', \OC\Files\Filesystem::normalizePath('//', false));
$this->assertEquals('/path', \OC\Files\Filesystem::normalizePath('/path/'));
$this->assertEquals('/path/', \OC\Files\Filesystem::normalizePath('/path/', false));
$this->assertEquals('/path', \OC\Files\Filesystem::normalizePath('path'));
- $this->assertEquals('/path', \OC\Files\Filesystem::normalizePath('\path'));
$this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('/foo//bar/'));
+ $this->assertEquals('/foo/bar/', \OC\Files\Filesystem::normalizePath('/foo//bar/', false));
$this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('/foo////bar'));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('/foo/////bar'));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('/foo/bar/.'));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('/foo/bar/./'));
+ $this->assertEquals('/foo/bar/', \OC\Files\Filesystem::normalizePath('/foo/bar/./', false));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('/foo/bar/./.'));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('/foo/bar/././'));
+ $this->assertEquals('/foo/bar/', \OC\Files\Filesystem::normalizePath('/foo/bar/././', false));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('/foo/./bar/'));
+ $this->assertEquals('/foo/bar/', \OC\Files\Filesystem::normalizePath('/foo/./bar/', false));
+ $this->assertEquals('/foo/.bar', \OC\Files\Filesystem::normalizePath('/foo/.bar/'));
+ $this->assertEquals('/foo/.bar/', \OC\Files\Filesystem::normalizePath('/foo/.bar/', false));
+ $this->assertEquals('/foo/.bar/tee', \OC\Files\Filesystem::normalizePath('/foo/.bar/tee'));
+
+ // normalize does not resolve '..' (by design)
+ $this->assertEquals('/foo/..', \OC\Files\Filesystem::normalizePath('/foo/../'));
+
if (class_exists('Patchwork\PHP\Shim\Normalizer')) {
$this->assertEquals("/foo/bar\xC3\xBC", \OC\Files\Filesystem::normalizePath("/foo/baru\xCC\x88"));
}
}
+ public function testNormalizeWindowsPaths() {
+ $this->assertEquals('/', \OC\Files\Filesystem::normalizePath(''));
+ $this->assertEquals('/', \OC\Files\Filesystem::normalizePath('\\'));
+ $this->assertEquals('/', \OC\Files\Filesystem::normalizePath('\\', false));
+ $this->assertEquals('/', \OC\Files\Filesystem::normalizePath('\\\\'));
+ $this->assertEquals('/', \OC\Files\Filesystem::normalizePath('\\\\', false));
+ $this->assertEquals('/path', \OC\Files\Filesystem::normalizePath('\\path\\'));
+ $this->assertEquals('/path/', \OC\Files\Filesystem::normalizePath('\\path\\', false));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('\\foo\\\\bar\\'));
+ $this->assertEquals('/foo/bar/', \OC\Files\Filesystem::normalizePath('\\foo\\\\bar\\', false));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('\\foo\\\\\\\\bar'));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('\\foo\\\\\\\\\\bar'));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('\\foo\\bar\\.'));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('\\foo\\bar\\.\\'));
+ $this->assertEquals('/foo/bar/', \OC\Files\Filesystem::normalizePath('\\foo\\bar\\.\\', false));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('\\foo\\bar\\.\\.'));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('\\foo\\bar\\.\\.\\'));
+ $this->assertEquals('/foo/bar/', \OC\Files\Filesystem::normalizePath('\\foo\\bar\\.\\.\\', false));
+ $this->assertEquals('/foo/bar', \OC\Files\Filesystem::normalizePath('\\foo\\.\\bar\\'));
+ $this->assertEquals('/foo/bar/', \OC\Files\Filesystem::normalizePath('\\foo\\.\\bar\\', false));
+ $this->assertEquals('/foo/.bar', \OC\Files\Filesystem::normalizePath('\\foo\\.bar\\'));
+ $this->assertEquals('/foo/.bar/', \OC\Files\Filesystem::normalizePath('\\foo\\.bar\\', false));
+ $this->assertEquals('/foo/.bar/tee', \OC\Files\Filesystem::normalizePath('\\foo\\.bar\\tee'));
+
+ // normalize does not resolve '..' (by design)
+ $this->assertEquals('/foo/..', \OC\Files\Filesystem::normalizePath('\\foo\\..\\'));
+
+ if (class_exists('Patchwork\PHP\Shim\Normalizer')) {
+ $this->assertEquals("/foo/bar\xC3\xBC", \OC\Files\Filesystem::normalizePath("\\foo\\baru\xCC\x88"));
+ }
+ }
+
public function testHooks() {
if(\OC\Files\Filesystem::getView()){
$user = \OC_User::getUser();