From 15b39887c54436ccc35ea542705db917e544ba6f Mon Sep 17 00:00:00 2001 From: Outfluencer <48880402+Outfluencer@users.noreply.github.com> Date: Sat, 26 Jun 2021 10:08:18 +1000 Subject: [PATCH] #3133: Directly disconnect on illegal chars --- .../java/net/md_5/bungee/connection/UpstreamBridge.java | 7 ++++++- proxy/src/main/resources/messages.properties | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java index 5f7f3c4d..c21bdefa 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java @@ -147,7 +147,12 @@ public class UpstreamBridge extends PacketHandler for ( int index = 0, length = chat.getMessage().length(); index < length; index++ ) { char c = chat.getMessage().charAt( index ); - Preconditions.checkArgument( c != '\u00A7' && c >= ' ' && c != 127, "illegal characters in chat" ); // Section symbol, control sequences, and delete + // Section symbol, control sequences, and delete + if ( c == '\u00A7' || c < ' ' || c == 127 ) + { + con.disconnect( bungee.getTranslation( "illegal_chat_characters", String.format( "\\u%04x", (int) c ) ) ); + throw CancelSendSignal.INSTANCE; + } } ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.getMessage() ); diff --git a/proxy/src/main/resources/messages.properties b/proxy/src/main/resources/messages.properties index e114cdcf..c6dedba4 100644 --- a/proxy/src/main/resources/messages.properties +++ b/proxy/src/main/resources/messages.properties @@ -39,3 +39,4 @@ you_got_summoned=\u00a76Summoned to {0} by {1} command_perms_groups=\u00a76You have the following groups: {0} command_perms_permission=\u00a79- {0} command_ip=\u00a79IP of {0} is {1} +illegal_chat_characters=\u00a7cillegal characters in chat ({0})