From ec5f05c3458eee4d572f3a6a935f5ed8030ba819 Mon Sep 17 00:00:00 2001 From: Shayne Hartford Date: Mon, 27 Feb 2023 10:45:04 -0500 Subject: Change Windows env from USERPROFILE to APPDATA (#77) --- azalea-client/src/get_mc_dir.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'azalea-client/src') diff --git a/azalea-client/src/get_mc_dir.rs b/azalea-client/src/get_mc_dir.rs index 440550a7..df2a81aa 100755 --- a/azalea-client/src/get_mc_dir.rs +++ b/azalea-client/src/get_mc_dir.rs @@ -23,7 +23,7 @@ pub fn minecraft_dir() -> Option { pub fn home_env_var() -> &'static str { #[cfg(target_os = "windows")] { - "USERPROFILE" + "APPDATA" } #[cfg(target_os = "macos")] { -- cgit v1.2.3 From 91d97adb4f03acf2d53dedb598f5496e2c4d9063 Mon Sep 17 00:00:00 2001 From: Shayne Hartford Date: Mon, 27 Feb 2023 22:44:45 -0500 Subject: Remove invalid characters and truncate messages and commands to 256 (#78) * Remove invalid characters and truncate messages and commands to 256 * Remove duplicated use statements * Remove to_owned and use matches! macro --- azalea-client/src/chat.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'azalea-client/src') diff --git a/azalea-client/src/chat.rs b/azalea-client/src/chat.rs index 202cf47c..e127f0d7 100755 --- a/azalea-client/src/chat.rs +++ b/azalea-client/src/chat.rs @@ -149,6 +149,7 @@ impl Client { entity: self.entity, content: content.to_string(), }); + self.run_schedule_sender.send(()).unwrap(); } } @@ -228,9 +229,15 @@ fn handle_send_chat_kind_event( mut send_packet_events: EventWriter, ) { for event in events.iter() { + let content = event + .content + .chars() + .filter(|c| !matches!(c, '\x00'..='\x1F' | '\x7F' | 'ยง')) + .take(256) + .collect::(); let packet = match event.kind { ChatPacketKind::Message => ServerboundChatPacket { - message: event.content.clone(), + message: content, timestamp: SystemTime::now() .duration_since(UNIX_EPOCH) .expect("Time shouldn't be before epoch") @@ -245,7 +252,7 @@ fn handle_send_chat_kind_event( ChatPacketKind::Command => { // TODO: chat signing ServerboundChatCommandPacket { - command: event.content.clone(), + command: content, timestamp: SystemTime::now() .duration_since(UNIX_EPOCH) .expect("Time shouldn't be before epoch") -- cgit v1.2.3