Skip to content

Commit a2ac818

Browse files
authored
Merge pull request #38517 from nextcloud/backport/38496/stable26
[stable26] fix: catch errors in id3parser library
2 parents 5b02df2 + ef0cffc commit a2ac818

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/private/Preview/MP3.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
use OCP\Files\File;
3434
use OCP\IImage;
35+
use Psr\Log\LoggerInterface;
3536

3637
class MP3 extends ProviderV2 {
3738
/**
@@ -48,8 +49,18 @@ public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
4849
$getID3 = new ID3Parser();
4950

5051
$tmpPath = $this->getLocalFile($file);
51-
$tags = $getID3->analyze($tmpPath);
52-
$this->cleanTmpFiles();
52+
try {
53+
$tags = $getID3->analyze($tmpPath);
54+
} catch (\Throwable $e) {
55+
\OC::$server->get(LoggerInterface::class)->info($e->getMessage(), [
56+
'exception' => $e,
57+
'app' => 'core',
58+
]);
59+
return null;
60+
} finally {
61+
$this->cleanTmpFiles();
62+
}
63+
5364
$picture = isset($tags['id3v2']['APIC'][0]['data']) ? $tags['id3v2']['APIC'][0]['data'] : null;
5465
if (is_null($picture) && isset($tags['id3v2']['PIC'][0]['data'])) {
5566
$picture = $tags['id3v2']['PIC'][0]['data'];

0 commit comments

Comments
 (0)