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.
This commit is contained in:
parent
301dfdc200
commit
64fc29796d
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue