reject single-layer alex texture

This commit is contained in:
Pig Fang 2021-02-13 15:19:12 +08:00
parent 6f97c1efcc
commit 89bb2b4db9
No known key found for this signature in database
GPG Key ID: A8198F548DADA9E2
2 changed files with 14 additions and 1 deletions

View File

@ -221,7 +221,7 @@ class SkinlibController extends Controller
$size = getimagesize($file);
$ratio = $size[0] / $size[1];
if ($type == 'steve' || $type == 'alex') {
if ($ratio != 2 && $ratio != 1) {
if ($ratio != 2 && $ratio != 1 || $type === 'alex' && $ratio === 2) {
$message = trans('skinlib.upload.invalid-size', [
'type' => trans('general.skin'),
'width' => $size[0],

View File

@ -321,6 +321,19 @@ class SkinlibControllerTest extends TestCase
'name' => 'texture',
'public' => true,
'type' => 'alex',
'file' => UploadedFile::fake()->image('texture.png', 64, 32),
])->assertJson([
'code' => 1,
'message' => trans('skinlib.upload.invalid-size', [
'type' => trans('general.skin'),
'width' => 64,
'height' => 32,
]),
]);
$this->postJson(route('texture.upload'), [
'name' => 'texture',
'public' => true,
'type' => 'steve',
'file' => UploadedFile::fake()->image('texture.png', 100, 50),
])->assertJson([
'code' => 1,