Fix illegal texturePayload may cause crash

This commit is contained in:
yushijinhun 2019-05-02 12:35:43 +08:00
parent adc360eaaa
commit 43fb3ca10a
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4

View File

@ -165,7 +165,13 @@ public class YggdrasilService {
String encodedTextures = profile.getProperties().get("textures");
if (encodedTextures != null) {
TextureResponse texturePayload = fromJson(new String(Base64.getDecoder().decode(encodedTextures), UTF_8), TextureResponse.class);
byte[] decodedBinary;
try {
decodedBinary = Base64.getDecoder().decode(encodedTextures);
} catch (IllegalArgumentException e) {
throw new ServerResponseMalformedException(e);
}
TextureResponse texturePayload = fromJson(new String(decodedBinary, UTF_8), TextureResponse.class);
return Optional.ofNullable(texturePayload.textures);
} else {
return Optional.empty();