1
0
Fork 0

Check imported emojis for mimetype

Signed-off-by: Nils van Lück <nils@vanlueck.dev>
This commit is contained in:
Nils van Lück 2022-12-08 21:10:10 +01:00
parent af28aecf21
commit c96bcd559d
1 changed files with 9 additions and 1 deletions

View File

@ -52,7 +52,7 @@ class ImportEmojis extends Command
foreach (new \RecursiveIteratorIterator($tar) as $entry) {
$this->line("Processing {$entry->getFilename()}");
if (!$entry->isFile() || !$this->isImage($entry)) {
if (!$entry->isFile() || !$this->isImage($entry) || !$this->isEmoji($entry->getPathname())) {
$failed++;
continue;
}
@ -107,4 +107,12 @@ class ImportEmojis extends Command
$image = getimagesize($file->getPathname());
return $image !== false;
}
private function isEmoji($filename)
{
$allowedMimeTypes = ['image/png', 'image/jpeg', 'image/webp'];
$mimeType = mime_content_type($filename);
return in_array($mimeType, $allowedMimeTypes);
}
}