summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-11-17 09:19:10 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-11-19 14:51:38 +0000
commitf0661de4e554210b97d7a2d8f003df7dd7063465 (patch)
treec67842a0ab59951f36d0258eea18007c94a71542 /tests
parent516b10de334295a5cf94238ac19c6a36dfbf9c77 (diff)
downloadnextcloud-server-f0661de4e554210b97d7a2d8f003df7dd7063465.tar.gz
nextcloud-server-f0661de4e554210b97d7a2d8f003df7dd7063465.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']);
+ }
}