mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
ignore bad utf8
This commit is contained in:
parent
8de73c336f
commit
ad8b1b7b24
4 changed files with 12 additions and 3 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -246,6 +246,7 @@ dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"criterion",
|
"criterion",
|
||||||
"flate2",
|
"flate2",
|
||||||
|
"log",
|
||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
|
@ -583,8 +583,7 @@ impl Client {
|
||||||
client
|
client
|
||||||
.dimension
|
.dimension
|
||||||
.lock()
|
.lock()
|
||||||
.replace_with_packet_data(&pos, &mut Cursor::new(&p.chunk_data.data))
|
.replace_with_packet_data(&pos, &mut Cursor::new(&p.chunk_data.data));
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
ClientboundGamePacket::LightUpdate(_p) => {
|
ClientboundGamePacket::LightUpdate(_p) => {
|
||||||
// debug!("Got light update packet {:?}", p);
|
// debug!("Got light update packet {:?}", p);
|
||||||
|
|
|
@ -13,6 +13,7 @@ ahash = "^0.8.0"
|
||||||
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
azalea-buf = {path = "../azalea-buf", version = "^0.3.0" }
|
||||||
byteorder = "^1.4.3"
|
byteorder = "^1.4.3"
|
||||||
flate2 = "^1.0.23"
|
flate2 = "^1.0.23"
|
||||||
|
log = "0.4.17"
|
||||||
num-derive = "^0.3.3"
|
num-derive = "^0.3.3"
|
||||||
num-traits = "^0.2.14"
|
num-traits = "^0.2.14"
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ use ahash::AHashMap;
|
||||||
use azalea_buf::{BufReadError, McBufReadable};
|
use azalea_buf::{BufReadError, McBufReadable};
|
||||||
use byteorder::{ReadBytesExt, BE};
|
use byteorder::{ReadBytesExt, BE};
|
||||||
use flate2::read::{GzDecoder, ZlibDecoder};
|
use flate2::read::{GzDecoder, ZlibDecoder};
|
||||||
|
use log::warn;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::io::{BufRead, Read};
|
use std::io::{BufRead, Read};
|
||||||
|
|
||||||
|
@ -23,7 +24,14 @@ fn read_string(stream: &mut Cursor<&[u8]>) -> Result<String, Error> {
|
||||||
let length = stream.read_u16::<BE>()? as usize;
|
let length = stream.read_u16::<BE>()? as usize;
|
||||||
|
|
||||||
let buf = read_bytes(stream, length)?;
|
let buf = read_bytes(stream, length)?;
|
||||||
Ok(std::str::from_utf8(buf)?.to_string())
|
|
||||||
|
Ok(if let Ok(string) = std::str::from_utf8(buf) {
|
||||||
|
string.to_string()
|
||||||
|
} else {
|
||||||
|
let lossy_string = String::from_utf8_lossy(buf).into_owned();
|
||||||
|
warn!("Error decoding utf8 (bytes: {buf:?}, lossy: \"{lossy_string})\"");
|
||||||
|
lossy_string
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tag {
|
impl Tag {
|
||||||
|
|
Loading…
Add table
Reference in a new issue