Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2022-06-09 09:59:56 +0300
committerJulius Härtl <jus@bitgrid.net>2022-06-09 09:59:56 +0300
commit5e925250938ecf2716d786ed4811d2c49a8cb061 (patch)
treec9b8dabc1891d9b5a0bb9097981d74770bd75ecd /lib
parente050c15c23ff624304c41aa8b327b95bf30afb30 (diff)
An empty string is a valid encoded result
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/Service/ApiService.php2
-rw-r--r--lib/Service/EncodingService.php3
-rw-r--r--lib/TextFile.php2
3 files changed, 4 insertions, 3 deletions
diff --git a/lib/Service/ApiService.php b/lib/Service/ApiService.php
index 5ed1b3e79..651b1eefc 100644
--- a/lib/Service/ApiService.php
+++ b/lib/Service/ApiService.php
@@ -111,7 +111,7 @@ class ApiService {
$content = $baseFile->getContent();
$content = $this->encodingService->encodeToUtf8($content);
- if (!$content) {
+ if ($content === null) {
$this->logger->log(ILogger::WARN, 'Failed to encode file to UTF8. File ID: ' . $file->getId());
}
} catch (NotFoundException $e) {
diff --git a/lib/Service/EncodingService.php b/lib/Service/EncodingService.php
index 3f5bada06..5026cd9a3 100644
--- a/lib/Service/EncodingService.php
+++ b/lib/Service/EncodingService.php
@@ -42,7 +42,8 @@ class EncodingService {
return null;
}
- return mb_convert_encoding($string, 'UTF-8', $encoding);
+ $encoded = mb_convert_encoding($string, 'UTF-8', $encoding);
+ return is_string($encoded) ? $encoded : null;
}
public function detectEncoding(string $string): ?string {
diff --git a/lib/TextFile.php b/lib/TextFile.php
index 30b58c84c..9d632dcfe 100644
--- a/lib/TextFile.php
+++ b/lib/TextFile.php
@@ -63,7 +63,7 @@ class TextFile implements ISimpleFile {
public function getContent() {
$content = $this->encodingService->encodeToUtf8($this->file->getContent());
- if (!$content) {
+ if ($content === null) {
throw new NotFoundException('File not compatible with text because it could not be encoded to UTF-8.');
}