diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-02-06 15:09:31 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-02-06 15:09:31 +0100 |
commit | cbf8dd439c5e56a56511e39180d014ce2ecd5221 (patch) | |
tree | b081e5497e06f21aaaf90fa95015607b5fddcd18 /tests | |
parent | c658ec658a2daca90649a8ddb10b5cedb7963b95 (diff) | |
download | nextcloud-server-cbf8dd439c5e56a56511e39180d014ce2ecd5221.tar.gz nextcloud-server-cbf8dd439c5e56a56511e39180d014ce2ecd5221.zip |
Normalize before processing
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/filesystem.php | 22 | ||||
-rw-r--r-- | tests/lib/files/mapper.php | 16 |
2 files changed, 37 insertions, 1 deletions
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index 88e98fbb8c6..0a5ae40d994 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -108,6 +108,28 @@ class Filesystem extends \Test\TestCase { } } + public function isFileBlacklistedData() { + return array( + array('/etc/foo/bar/foo.txt', false), + array('\etc\foo/bar\foo.txt', false), + array('.htaccess', true), + array('.htaccess/', true), + array('.htaccess\\', true), + array('/etc/foo\bar/.htaccess\\', true), + array('/etc/foo\bar/.htaccess/', true), + array('/etc/foo\bar/.htaccess/foo', false), + array('//foo//bar/\.htaccess/', true), + array('\foo\bar\.HTAccess', true), + ); + } + + /** + * @dataProvider isFileBlacklistedData + */ + public function testIsFileBlacklisted($path, $expected) { + $this->assertSame($expected, \OC\Files\Filesystem::isFileBlacklisted($path)); + } + public function testNormalizeWindowsPaths() { $this->assertEquals('/', \OC\Files\Filesystem::normalizePath('')); $this->assertEquals('/', \OC\Files\Filesystem::normalizePath('\\')); diff --git a/tests/lib/files/mapper.php b/tests/lib/files/mapper.php index 48ae95b7e72..d786de235cb 100644 --- a/tests/lib/files/mapper.php +++ b/tests/lib/files/mapper.php @@ -59,6 +59,20 @@ class Mapper extends \PHPUnit_Framework_TestCase { $this->assertEquals('D:/folder.name.with.peri-ods/te-st-2.t-x-t', $this->mapper->slugifyPath('D:/folder.name.with.peri ods/te st.t x t', 2)); $this->assertEquals('D:/folder.name.with.peri-ods/te-st.t-x-t', $this->mapper->slugifyPath('D:/folder.name.with.peri ods/te st.t x t')); - + // files with special characters + $this->assertEquals('D:/' . md5('ありがとう'), $this->mapper->slugifyPath('D:/ありがとう')); + $this->assertEquals('D:/' . md5('ありがとう') . '/issue6722.txt', $this->mapper->slugifyPath('D:/ありがとう/issue6722.txt')); + + // blacklisted files + $this->assertEquals('D:/' . md5('.htaccess'), $this->mapper->slugifyPath('D:/.htaccess')); + $this->assertEquals('D:/' . md5('.htaccess.'), $this->mapper->slugifyPath('D:/.htaccess.')); + $this->assertEquals('D:/' . md5('.htAccess'), $this->mapper->slugifyPath('D:/.htAccess')); + $this->assertEquals('D:/' . md5('.htAccess\\…\\') . '/a', $this->mapper->slugifyPath('D:/.htAccess\…\/とa')); + $this->assertEquals('D:/' . md5('.htaccess-'), $this->mapper->slugifyPath('D:/.htaccess-')); + $this->assertEquals('D:/' . md5('.htaあccess'), $this->mapper->slugifyPath('D:/.htaあccess')); + $this->assertEquals('D:/' . md5(' .htaccess'), $this->mapper->slugifyPath('D:/ .htaccess')); + $this->assertEquals('D:/' . md5('.htaccess '), $this->mapper->slugifyPath('D:/.htaccess ')); + $this->assertEquals('D:/' . md5(' .htaccess '), $this->mapper->slugifyPath('D:/ .htaccess ')); + } } |