fix: check texture size for capes
This commit is contained in:
parent
6226784b10
commit
b7af1ebf19
|
|
@ -219,6 +219,17 @@ class SkinlibController extends Controller
|
|||
|
||||
$type = $data['type'];
|
||||
$size = getimagesize($file);
|
||||
|
||||
if ($size[0] % 64 != 0 || $size[1] % 32 != 0) {
|
||||
$message = trans('skinlib.upload.invalid-size', [
|
||||
'type' => $type === 'cape' ? trans('general.cape') : trans('general.skin'),
|
||||
'width' => $size[0],
|
||||
'height' => $size[1],
|
||||
]);
|
||||
|
||||
return json($message, 1);
|
||||
}
|
||||
|
||||
$ratio = $size[0] / $size[1];
|
||||
if ($type == 'steve' || $type == 'alex') {
|
||||
if ($ratio != 2 && $ratio != 1 || $type === 'alex' && $ratio === 2) {
|
||||
|
|
@ -228,15 +239,6 @@ class SkinlibController extends Controller
|
|||
'height' => $size[1],
|
||||
]);
|
||||
|
||||
return json($message, 1);
|
||||
}
|
||||
if ($size[0] % 64 != 0 || $size[1] % 32 != 0) {
|
||||
$message = trans('skinlib.upload.invalid-hd-skin', [
|
||||
'type' => trans('general.skin'),
|
||||
'width' => $size[0],
|
||||
'height' => $size[1],
|
||||
]);
|
||||
|
||||
return json($message, 1);
|
||||
}
|
||||
} elseif ($type == 'cape') {
|
||||
|
|
|
|||
|
|
@ -337,12 +337,25 @@ class SkinlibControllerTest extends TestCase
|
|||
'file' => UploadedFile::fake()->image('texture.png', 100, 50),
|
||||
])->assertJson([
|
||||
'code' => 1,
|
||||
'message' => trans('skinlib.upload.invalid-hd-skin', [
|
||||
'message' => trans('skinlib.upload.invalid-size', [
|
||||
'type' => trans('general.skin'),
|
||||
'width' => 100,
|
||||
'height' => 50,
|
||||
]),
|
||||
]);
|
||||
$this->postJson(route('texture.upload'), [
|
||||
'name' => 'texture',
|
||||
'public' => true,
|
||||
'type' => 'cape',
|
||||
'file' => UploadedFile::fake()->image('texture.png', 100, 50),
|
||||
])->assertJson([
|
||||
'code' => 1,
|
||||
'message' => trans('skinlib.upload.invalid-size', [
|
||||
'type' => trans('general.cape'),
|
||||
'width' => 100,
|
||||
'height' => 50,
|
||||
]),
|
||||
]);
|
||||
$this->postJson(route('texture.upload'), [
|
||||
'name' => 'texture',
|
||||
'public' => true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user