Add check to ensure finfo_open works in ensure_file function
This commit is contained in:
parent
306efa3769
commit
cb8c786284
|
@ -397,13 +397,15 @@ final class MD_STD {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$finfo = \finfo_open(FILEINFO_MIME_TYPE);
|
if (!($finfo = \finfo_open(FILEINFO_MIME_TYPE))) {
|
||||||
|
throw new Exception("Cannot open finfo context");
|
||||||
|
}
|
||||||
if (!($mime_type = finfo_file($finfo, $filepath))) {
|
if (!($mime_type = finfo_file($finfo, $filepath))) {
|
||||||
throw new MDWrongFileType("Cannot get mime type of file: " . basename($filepath));
|
throw new MDWrongFileType("Cannot get mime type of file: " . basename($filepath));
|
||||||
}
|
}
|
||||||
\finfo_close($finfo);
|
\finfo_close($finfo);
|
||||||
|
|
||||||
if (!\in_array($mime_type, $accepted_mimetype)) {
|
if (!\in_array($mime_type, $accepted_mimetype, true)) {
|
||||||
throw new MDWrongFileType("Incorrect mime type of file " . \basename($filepath) . ". Mime type is " . \mime_content_type($filepath) . ", accepted any of ['" . \implode("', '", $accepted_mimetype) . "']");
|
throw new MDWrongFileType("Incorrect mime type of file " . \basename($filepath) . ". Mime type is " . \mime_content_type($filepath) . ", accepted any of ['" . \implode("', '", $accepted_mimetype) . "']");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user