summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-11-17 09:19:10 +0100
committerVincent Petry <vincent@nextcloud.com>2021-11-17 09:43:25 +0100
commitc92a0e415260dccb9092b9312ccd727de81bd0f7 (patch)
treee44c698206ca82b7091cf1c272e4e6132a6ac9f7 /tests
parent67ebe75d0ee02977b95e43a31516d936d18514a2 (diff)
downloadnextcloud-server-c92a0e415260dccb9092b9312ccd727de81bd0f7.tar.gz
nextcloud-server-c92a0e415260dccb9092b9312ccd727de81bd0f7.zip
Normalize directory entries in Encoding wrapper
Directory entry file names are now normalized in getMetaData(), getDirectoryContents() and opendir(). This makes the scanner work properly as it assumes pre-normalized names. In case the names were not normalized, the scanner will now skip the entries and display a warning when applicable. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncodingTest.php44
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/lib/Files/Storage/Wrapper/EncodingTest.php b/tests/lib/Files/Storage/Wrapper/EncodingTest.php
index 498d9f78248..0901edf83fa 100644
--- a/tests/lib/Files/Storage/Wrapper/EncodingTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncodingTest.php
@@ -32,7 +32,7 @@ class EncodingTest extends \Test\Files\Storage\Storage {
public function directoryProvider() {
$a = parent::directoryProvider();
- $a[] = [self::NFD_NAME];
+ $a[] = [self::NFC_NAME];
return $a;
}
@@ -199,4 +199,46 @@ class EncodingTest extends \Test\Files\Storage\Storage {
$this->assertEquals('bar', $this->instance->file_get_contents(self::NFC_NAME . '2/test2.txt'));
}
+
+ public function testNormalizedDirectoryEntriesOpenDir() {
+ $this->sourceStorage->mkdir('/test');
+ $this->sourceStorage->mkdir('/test/' . self::NFD_NAME);
+
+ $this->assertTrue($this->instance->file_exists('/test/' . self::NFC_NAME));
+ $this->assertTrue($this->instance->file_exists('/test/' . self::NFD_NAME));
+
+ $dh = $this->instance->opendir('/test');
+ $content = [];
+ while ($file = readdir($dh)) {
+ if ($file != '.' and $file != '..') {
+ $content[] = $file;
+ }
+ }
+
+ $this->assertCount(1, $content);
+ $this->assertEquals(self::NFC_NAME, $content[0]);
+ }
+
+ public function testNormalizedDirectoryEntriesGetDirectoryContent() {
+ $this->sourceStorage->mkdir('/test');
+ $this->sourceStorage->mkdir('/test/' . self::NFD_NAME);
+
+ $this->assertTrue($this->instance->file_exists('/test/' . self::NFC_NAME));
+ $this->assertTrue($this->instance->file_exists('/test/' . self::NFD_NAME));
+
+ $content = iterator_to_array($this->instance->getDirectoryContent('/test'));
+ $this->assertCount(1, $content);
+ $this->assertEquals(self::NFC_NAME, $content[0]['name']);
+ }
+
+ public function testNormalizedGetMetaData() {
+ $this->sourceStorage->mkdir('/test');
+ $this->sourceStorage->mkdir('/test/' . self::NFD_NAME);
+
+ $entry = $this->instance->getMetaData('/test/' . self::NFC_NAME);
+ $this->assertEquals(self::NFC_NAME, $entry['name']);
+
+ $entry = $this->instance->getMetaData('/test/' . self::NFD_NAME);
+ $this->assertEquals(self::NFC_NAME, $entry['name']);
+ }
}