diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-02-06 17:22:25 +0300 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-02-06 17:53:13 +0300 |
commit | 267341fbeba5d1ef110b50e7cead9b0d26068fc1 (patch) | |
tree | 38bbd1db32469d4b62eb392df3fb5fb71ab6d2f3 /tests | |
parent | 0bccd06bc803c56fbdbd9eef84232de83fa106ba (diff) |
Normalize before processing
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/filesystem.php | 22 | ||||
-rw-r--r-- | tests/lib/files/mapper.php | 11 |
2 files changed, 32 insertions, 1 deletions
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php index b0ed065571d..6c83afc2b17 100644 --- a/tests/lib/files/filesystem.php +++ b/tests/lib/files/filesystem.php @@ -101,6 +101,28 @@ class Filesystem extends \PHPUnit_Framework_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..1b9685ba0e6 100644 --- a/tests/lib/files/mapper.php +++ b/tests/lib/files/mapper.php @@ -59,6 +59,15 @@ 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')); - + // blacklisted files + $this->assertNotEquals('D:/.htaccess', $this->mapper->slugifyPath(' D:/.htaccess')); + $this->assertNotEquals('D:/.htaccess', $this->mapper->slugifyPath('D:/.htaccess ')); + $this->assertNotEquals('D:/.htaccess', $this->mapper->slugifyPath(' D:/.htaccess ')); + $this->assertNotEquals('D:/.htaccess', $this->mapper->slugifyPath('D:/.htaccess')); + $this->assertNotEquals('D:/.htaccess', $this->mapper->slugifyPath('D:/.htaccess.')); + $this->assertNotEquals('D:/.htaccess', $this->mapper->slugifyPath('D:/.htAccess')); + $this->assertNotEquals('D:/.htaccess', $this->mapper->slugifyPath('D:/.htAccess\…\/とa')); + $this->assertNotEquals('D:/.htaccess', $this->mapper->slugifyPath('D:/.htaccess-')); + $this->assertNotEquals('D:/.htaccess', $this->mapper->slugifyPath('D:/.htaあccess')); } } |