DataUploadEvent already asserts that file exist

This commit is contained in:
Shish 2020-02-23 16:13:08 +00:00
parent c5d8585824
commit 77fc510bb3
6 changed files with 3 additions and 27 deletions

View File

@ -54,10 +54,6 @@ class FlashFileHandler extends DataHandlerExtension
protected function check_contents(string $tmpname): bool protected function check_contents(string $tmpname): bool
{ {
if (!file_exists($tmpname)) {
return false;
}
$fp = fopen($tmpname, "r"); $fp = fopen($tmpname, "r");
$head = fread($fp, 3); $head = fread($fp, 3);
fclose($fp); fclose($fp);

View File

@ -48,9 +48,6 @@ class IcoFileHandler extends DataHandlerExtension
protected function check_contents(string $file): bool protected function check_contents(string $file): bool
{ {
if (!file_exists($file)) {
return false;
}
$fp = fopen($file, "r"); $fp = fopen($file, "r");
$header = unpack("Snull/Stype/Scount", fread($fp, 6)); $header = unpack("Snull/Stype/Scount", fread($fp, 6));
fclose($fp); fclose($fp);

View File

@ -51,14 +51,7 @@ class MP3FileHandler extends DataHandlerExtension
protected function check_contents(string $tmpname): bool protected function check_contents(string $tmpname): bool
{ {
$success = false; $mimeType = getMimeType($tmpname);
return ($mimeType == 'audio/mpeg');
if (file_exists($tmpname)) {
$mimeType = getMimeType($tmpname);
$success = ($mimeType == 'audio/mpeg');
}
return $success;
} }
} }

View File

@ -63,9 +63,6 @@ class PixelFileHandler extends DataHandlerExtension
protected function check_contents(string $tmpname): bool protected function check_contents(string $tmpname): bool
{ {
$valid = [IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_WEBP]; $valid = [IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_WEBP];
if (!file_exists($tmpname)) {
return false;
}
$info = getimagesize($tmpname); $info = getimagesize($tmpname);
if (!$info) { if (!$info) {
return false; return false;

View File

@ -98,10 +98,6 @@ class SVGFileHandler extends DataHandlerExtension
protected function check_contents(string $file): bool protected function check_contents(string $file): bool
{ {
if (!file_exists($file)) {
return false;
}
$msp = new MiniSVGParser($file); $msp = new MiniSVGParser($file);
return bool_escape($msp->valid); return bool_escape($msp->valid);
} }

View File

@ -126,9 +126,6 @@ class VideoFileHandler extends DataHandlerExtension
protected function check_contents(string $tmpname): bool protected function check_contents(string $tmpname): bool
{ {
return ( return in_array(getMimeType($tmpname), self::SUPPORTED_MIME);
file_exists($tmpname) &&
in_array(getMimeType($tmpname), self::SUPPORTED_MIME)
);
} }
} }