From 39e14eb95c0b88c6905c50816149d13a0c9746e9 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 21 Apr 2023 10:33:05 +0000 Subject: hotfix: make sure to not pass an empty path to fopen() --- Zotlabs/Thumbs/Epubthumb.php | 7 ++++++- Zotlabs/Thumbs/Mp3audio.php | 9 ++++++++- Zotlabs/Thumbs/Pdf.php | 6 +++++- Zotlabs/Thumbs/Text.php | 5 +++-- Zotlabs/Thumbs/Video.php | 13 ++++++++----- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Zotlabs/Thumbs/Epubthumb.php b/Zotlabs/Thumbs/Epubthumb.php index 22f1a5e8f..6ebbd8933 100644 --- a/Zotlabs/Thumbs/Epubthumb.php +++ b/Zotlabs/Thumbs/Epubthumb.php @@ -30,9 +30,14 @@ class Epubthumb { */ function Thumb($attach, $preview_style, $height = 300, $width = 300) { + $file = dbunescbin($attach['content']); + if (!$file) { + return; + } + $photo = false; - $ep = new \EPub(dbunescbin($attach['content'])); + $ep = new \EPub($file); $data = $ep->Cover(); if($data['found']) { diff --git a/Zotlabs/Thumbs/Mp3audio.php b/Zotlabs/Thumbs/Mp3audio.php index 000d65b22..c50338fb2 100644 --- a/Zotlabs/Thumbs/Mp3audio.php +++ b/Zotlabs/Thumbs/Mp3audio.php @@ -11,9 +11,16 @@ class Mp3audio { } function Thumb($attach,$preview_style,$height = 300, $width = 300) { + + $file = dbunescbin($attach['content']); + if (!$file) { + return; + } + + $photo = false; $p = new ID3Parser(); - $id = $p->analyze(dbunescbin($attach['content'])); + $id = $p->analyze($file); $photo = isset($id['id3v2']['APIC'][0]['data']) ? $id['id3v2']['APIC'][0]['data'] : null; if(is_null($photo) && isset($id['id3v2']['PIC'][0]['data'])) { diff --git a/Zotlabs/Thumbs/Pdf.php b/Zotlabs/Thumbs/Pdf.php index 11714ad53..6f9111ed3 100644 --- a/Zotlabs/Thumbs/Pdf.php +++ b/Zotlabs/Thumbs/Pdf.php @@ -11,9 +11,13 @@ class Pdf { function Thumb($attach,$preview_style,$height = 300, $width = 300) { + $file = dbunescbin($attach['content']); + if (!$file) { + return; + } + $photo = false; - $file = dbunescbin($attach['content']); $tmpfile = $file . '.pdf'; $outfile = $file . '.jpg'; diff --git a/Zotlabs/Thumbs/Text.php b/Zotlabs/Thumbs/Text.php index 31e27d014..b2f13c578 100644 --- a/Zotlabs/Thumbs/Text.php +++ b/Zotlabs/Thumbs/Text.php @@ -11,11 +11,12 @@ class Text { function Thumb($attach,$preview_style,$height = 300, $width = 300) { - if (empty($attach['content'])) { + $file = dbunescbin($attach['content']); + if (!$file) { return; } - $stream = @fopen(dbunescbin($attach['content']),'rb'); + $stream = @fopen($file,'rb'); if($stream) { $content = trim(stream_get_contents($stream,4096)); $content = str_replace("\r",'',$content); diff --git a/Zotlabs/Thumbs/Video.php b/Zotlabs/Thumbs/Video.php index 15d3ace12..9df27d703 100644 --- a/Zotlabs/Thumbs/Video.php +++ b/Zotlabs/Thumbs/Video.php @@ -11,16 +11,19 @@ class Video { function Thumb($attach,$preview_style,$height = 300, $width = 300) { + $file = dbunescbin($attach['content']); + if (!$file) { + return; + } + $photo = false; $t = explode('/',$attach['filetype']); if($t[1]) $extension = '.' . $t[1]; else - return; + return; - - $file = dbunescbin($attach['content']); $tmpfile = $file . $extension; $outfile = $file . '.jpg'; @@ -40,7 +43,7 @@ class Video { $ffmpeg = trim(shell_exec('which ffmpeg')); - if($ffmpeg) { + if($ffmpeg) { logger('ffmpeg not found in path. Video thumbnails may fail.'); } @@ -59,7 +62,7 @@ class Video { @rename($outfile,$file . '.thumb'); } } - + @unlink($tmpfile); } } -- cgit v1.2.3