don't allow to render avatar for non-skin texture

This commit is contained in:
Pig Fang 2020-10-18 12:12:28 +08:00
parent 311b0690fc
commit 9bfc0e6076
No known key found for this signature in database
GPG Key ID: A8198F548DADA9E2
2 changed files with 8 additions and 1 deletions

View File

@ -132,8 +132,12 @@ class TextureController extends Controller
return $this->avatar($minecraft, $request, $texture);
}
protected function avatar(Minecraft $minecraft, Request $request, Texture $texture = null)
protected function avatar(Minecraft $minecraft, Request $request, ?Texture $texture)
{
if (!empty($texture) && $texture->type !== 'steve' && $texture->type !== 'alex') {
return abort(422);
}
$size = (int) $request->query('size', 100);
$mode = $request->has('3d') ? '3d' : '2d';
$usePNG = $request->has('png') || !(imagetypes() & IMG_WEBP);

View File

@ -224,6 +224,9 @@ class TextureControllerTest extends TestCase
{
$disk = Storage::fake('textures');
$cape = Texture::factory()->cape()->create();
$this->get(route('avatar.texture', ['tid' => $cape->tid]))->assertStatus(422);
$this->get(route('avatar.texture', ['tid' => 0]))
->assertSuccessful()
->assertHeader('Content-Type', 'image/webp');