From ddab9a84c41682b98d67e2a13b3a45a2657f4c54 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 2 Feb 2014 12:20:37 +1100 Subject: [PATCH] Close #859 - more favicon validation --- .../net/md_5/bungee/conf/Configuration.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java index 3de33100..c54f1209 100644 --- a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java +++ b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java @@ -68,19 +68,25 @@ public class Configuration implements ProxyConfig try { BufferedImage image = ImageIO.read( fav ); - if ( image.getHeight() == 64 && image.getWidth() == 64 ) + if ( image != null ) { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - ImageIO.write( image, "png", bytes ); - favicon = "data:image/png;base64," + BaseEncoding.base64().encode( bytes.toByteArray() ); - if ( favicon.length() > Short.MAX_VALUE ) + if ( image.getHeight() == 64 && image.getWidth() == 64 ) { - ProxyServer.getInstance().getLogger().log( Level.WARNING, "Favicon file too large for server to process" ); - favicon = null; + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + ImageIO.write( image, "png", bytes ); + favicon = "data:image/png;base64," + BaseEncoding.base64().encode( bytes.toByteArray() ); + if ( favicon.length() > Short.MAX_VALUE ) + { + ProxyServer.getInstance().getLogger().log( Level.WARNING, "Favicon file too large for server to process" ); + favicon = null; + } + } else + { + ProxyServer.getInstance().getLogger().log( Level.WARNING, "Server icon must be exactly 64x64 pixels" ); } } else { - ProxyServer.getInstance().getLogger().log( Level.WARNING, "Server icon must be exactly 64x64 pixels" ); + ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not load server icon for unknown reason. Please double check its format." ); } } catch ( IOException ex ) {