diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2016-11-22 12:55:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-22 12:55:54 +0100 |
commit | df215625f195c266bc7bc38577f50c088f23df92 (patch) | |
tree | 70707a8bf54e662f17a24c66c4347b2e80f7f0d1 /tests | |
parent | b8732a1a534c49719f9f4e6fa4a6fc6b1e9e9090 (diff) | |
parent | 558f169671208fb349bb40de7b6e0abb02097832 (diff) | |
download | nextcloud-server-df215625f195c266bc7bc38577f50c088f23df92.tar.gz nextcloud-server-df215625f195c266bc7bc38577f50c088f23df92.zip |
Merge pull request #1972 from nextcloud/invalid-files-from-scanner
Make sure we don't scan files that can not be accessed
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/Cache/ScannerTest.php | 26 | ||||
-rw-r--r-- | tests/lib/Files/PathVerificationTest.php | 2 |
2 files changed, 27 insertions, 1 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'); diff --git a/tests/lib/Files/PathVerificationTest.php b/tests/lib/Files/PathVerificationTest.php index 12285bb7acd..c1cebe975fd 100644 --- a/tests/lib/Files/PathVerificationTest.php +++ b/tests/lib/Files/PathVerificationTest.php @@ -86,7 +86,7 @@ class PathVerificationTest extends \Test\TestCase { if (!$connection->supports4ByteText()) { $this->expectException(InvalidPathException::class); - $this->expectExceptionMessage('4-byte characters are not supported in file names'); + $this->expectExceptionMessage('File name contains at least one invalid character'); } $this->view->verifyPath('', $fileName); |