Skip to content

Commit

Permalink
reject single-layer alex texture
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Feb 13, 2021
1 parent 6f97c1e commit 89bb2b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Http/Controllers/SkinlibController.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function handleUpload(
$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],
Expand Down
13 changes: 13 additions & 0 deletions tests/HttpTest/ControllersTest/SkinlibControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,19 @@ public function testHandleUpload()
'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,
Expand Down

0 comments on commit 89bb2b4

Please sign in to comment.