forked from GNUsocial/gnu-social
[ENTITY][Attachment] Raise mimetype max length to 64 characters and ensure we don't attempt to store more than that
This commit is contained in:
parent
4d883d1011
commit
33bf99cfda
@ -70,7 +70,7 @@ class GSFile
|
||||
// Attachment Exists
|
||||
$attachment->livesIncrementAndGet();
|
||||
if (is_null($attachment->getFilename())) {
|
||||
$mimetype = $attachment->getMimetype();
|
||||
$mimetype = mb_substr($attachment->getMimetype(), 0, 64);
|
||||
$width = $attachment->getWidth();
|
||||
$height = $attachment->getHeight();
|
||||
Event::handle('AttachmentSanitization', [&$file, &$mimetype, &$width, &$height]);
|
||||
@ -86,7 +86,7 @@ class GSFile
|
||||
// Create an Attachment
|
||||
// The following properly gets the mimetype with `file` or other
|
||||
// available methods, so should be safe
|
||||
$mimetype = $file->getMimeType();
|
||||
$mimetype = mb_substr($file->getMimeType(), 0, 64);
|
||||
$width = $height = null;
|
||||
Event::handle('AttachmentSanitization', [&$file, &$mimetype, &$width, &$height]);
|
||||
$attachment = Attachment::create([
|
||||
|
@ -24,12 +24,12 @@ namespace App\Entity;
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\Entity;
|
||||
use App\Core\GSFile;
|
||||
use App\Util\Exception\DuplicateFoundException;
|
||||
use App\Util\Exception\NotFoundException;
|
||||
use App\Util\Exception\ServerException;
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Core\Log;
|
||||
use App\Util\Common;
|
||||
use App\Util\Exception\DuplicateFoundException;
|
||||
use App\Util\Exception\NotFoundException;
|
||||
use App\Util\Exception\ServerException;
|
||||
use DateTimeInterface;
|
||||
|
||||
/**
|
||||
@ -323,7 +323,7 @@ class Attachment extends Entity
|
||||
'id' => ['type' => 'serial', 'not null' => true],
|
||||
'lives' => ['type' => 'int', 'not null' => true, 'description' => 'RefCount'],
|
||||
'filehash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of the file contents, if the file is stored locally'],
|
||||
'mimetype' => ['type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'],
|
||||
'mimetype' => ['type' => 'varchar', 'length' => 64, 'description' => 'mime type of resource'],
|
||||
'filename' => ['type' => 'varchar', 'length' => 191, 'description' => 'file name of resource when available'],
|
||||
'size' => ['type' => 'int', 'description' => 'size of resource when available'],
|
||||
'width' => ['type' => 'int', 'description' => 'width in pixels, if it can be described as such and data is available'],
|
||||
|
Loading…
Reference in New Issue
Block a user