aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2023-05-28 00:30:47 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-05-30 09:06:35 +0000
commit5630703061ed0e5952968d0bfe7f88e04ba32245 (patch)
tree687d30153c74cee6a1c634e033f10427e36627cc /lib
parentd9ff25230c1b605bec865b553c943182e9fec3ce (diff)
downloadnextcloud-server-5630703061ed0e5952968d0bfe7f88e04ba32245.tar.gz
nextcloud-server-5630703061ed0e5952968d0bfe7f88e04ba32245.zip
fix: catch errors in id3parser library
We use a forked version of getID3 to read embedded images from mp3 files to use them as previews. If the library is unable to extract a image or fails on something different we should handle it properly. Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Preview/MP3.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/private/Preview/MP3.php b/lib/private/Preview/MP3.php
index 47d752af477..ff6ff86c966 100644
--- a/lib/private/Preview/MP3.php
+++ b/lib/private/Preview/MP3.php
@@ -32,6 +32,7 @@ use ID3Parser\ID3Parser;
use OCP\Files\File;
use OCP\IImage;
+use Psr\Log\LoggerInterface;
class MP3 extends ProviderV2 {
/**
@@ -48,8 +49,18 @@ class MP3 extends ProviderV2 {
$getID3 = new ID3Parser();
$tmpPath = $this->getLocalFile($file);
- $tags = $getID3->analyze($tmpPath);
- $this->cleanTmpFiles();
+ try {
+ $tags = $getID3->analyze($tmpPath);
+ } catch (\Throwable $e) {
+ \OC::$server->get(LoggerInterface::class)->info($e->getMessage(), [
+ 'exception' => $e,
+ 'app' => 'core',
+ ]);
+ return null;
+ } finally {
+ $this->cleanTmpFiles();
+ }
+
$picture = isset($tags['id3v2']['APIC'][0]['data']) ? $tags['id3v2']['APIC'][0]['data'] : null;
if (is_null($picture) && isset($tags['id3v2']['PIC'][0]['data'])) {
$picture = $tags['id3v2']['PIC'][0]['data'];