From 64fc29796d4a17fb93404c1bba36f1cafadb61b3 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Fri, 3 Jul 2020 11:20:08 -0700 Subject: [PATCH] server_list: fix pre-1.13 favicon data, #353 (#354) The server list ping response contains a base64-encoded favicon image, which in pre-1.13 servers can have embedded newlines: https://wiki.vg/Server_List_Ping#Response > The favicon should be a PNG image that is Base64 encoded (without > newlines: \n, new lines no longer work since 1.13) and prepended > with data:image/png;base64,. If this was the case, base64 decode would fail with a DecodeError, similar to Invalid byte (76, 10). We now strip the whitespace, so the base64 favicon can be decoded properly. --- src/screen/server_list.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/screen/server_list.rs b/src/screen/server_list.rs index bdec200..c41f913 100644 --- a/src/screen/server_list.rs +++ b/src/screen/server_list.rs @@ -266,6 +266,8 @@ impl ServerList { format::convert_legacy(&mut desc); let favicon = if let Some(icon) = res.0.favicon { let data_base64 = &icon["data:image/png;base64,".len()..]; + let data_base64: String = + data_base64.chars().filter(|c| !c.is_whitespace()).collect(); let data = base64::decode(data_base64).unwrap(); Some(image::load_from_memory(&data).unwrap()) } else {