diff options
author | Joas Schilling <coding@schilljs.com> | 2016-11-02 09:23:01 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-21 09:23:32 +0100 |
commit | 4652d203e37d06b427872888ccb17227c1e0818b (patch) | |
tree | 8941085906e572ca0b6114d7c9417e6eafab0f6a /tests | |
parent | ba9b17c9069c5d9fe8595ffd306647f33067c927 (diff) | |
download | nextcloud-server-4652d203e37d06b427872888ccb17227c1e0818b.tar.gz nextcloud-server-4652d203e37d06b427872888ccb17227c1e0818b.zip |
Make sure we don't scan files that can not be accessed
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/Cache/ScannerTest.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/lib/Files/Cache/ScannerTest.php b/tests/lib/Files/Cache/ScannerTest.php index b44b6f5d0f5..075716f8033 100644 --- a/tests/lib/Files/Cache/ScannerTest.php +++ b/tests/lib/Files/Cache/ScannerTest.php @@ -70,6 +70,32 @@ class ScannerTest extends \Test\TestCase { $this->assertEquals($cachedData['mimetype'], 'image/png'); } + function testFile4Byte() { + $data = "dummy file data\n"; + $this->storage->file_put_contents('foo🙈.txt', $data); + + if (\OC::$server->getDatabaseConnection()->supports4ByteText()) { + $this->assertNotNull($this->scanner->scanFile('foo🙈.txt')); + $this->assertTrue($this->cache->inCache('foo🙈.txt'), true); + + $cachedData = $this->cache->get('foo🙈.txt'); + $this->assertEquals(strlen($data), $cachedData['size']); + $this->assertEquals('text/plain', $cachedData['mimetype']); + $this->assertNotEquals(-1, $cachedData['parent']); //parent folders should be scanned automatically + } else { + $this->assertNull($this->scanner->scanFile('foo🙈.txt')); + $this->assertFalse($this->cache->inCache('foo🙈.txt'), true); + } + } + + function testFileInvalidChars() { + $data = "dummy file data\n"; + $this->storage->file_put_contents("foo\nbar.txt", $data); + + $this->assertNull($this->scanner->scanFile("foo\nbar.txt")); + $this->assertFalse($this->cache->inCache("foo\nbar.txt"), true); + } + private function fillTestFolders() { $textData = "dummy file data\n"; $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); |