diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-06-09 09:59:56 +0300 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2022-06-09 22:20:39 +0300 |
commit | 3d6b6298f665fa1661e45116be0c81c1a5e88b22 (patch) | |
tree | 05162b2ae2f58fffe24a240dac6a4886038795b4 /lib/Service | |
parent | a4bb1be2dbd27c3a1db8f12146cd8e3a8835c06a (diff) |
An empty string is a valid encoded result
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/Service')
-rw-r--r-- | lib/Service/ApiService.php | 2 | ||||
-rw-r--r-- | lib/Service/EncodingService.php | 3 |
2 files changed, 3 insertions, 2 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 { |