hotfix: make sure to not pass an empty path to fopen()

This commit is contained in:
Mario
2023-04-21 10:33:05 +00:00
parent f277d08244
commit 39e14eb95c
5 changed files with 30 additions and 10 deletions

View File

@@ -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']) {

View File

@@ -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'])) {

View File

@@ -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';

View File

@@ -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);

View File

@@ -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);
}
}