Waterfall/BungeeCord-Patches/0024-Validate-that-chat-messages-are-non-blank.patch
Thomas A ee819df91f Updated Upstream (BungeeCord)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

BungeeCord Changes:
6f7331e8 #3138, 3140: Check for the new leak detector netty flag
1b489bcc Attempt to fix java 8 native crash
da27924a #3115, #3125: Update natives build script, switch to Cloudflare zlib
15b39887 #3133: Directly disconnect on illegal chars
f9583a76 #3129: Replace ConnectTimeoutException with a more user-friendly string.
cb738188 #3126: Use suppliers instead of reflection for native impl generation.
a8b2f526 #3123: Apply exact vanilla string length limits for tab completion
ad50fc9a #3111: Check chat for illegal chars & moved length check into the packet class
2021-07-03 01:00:48 +02:00

34 lines
1.5 KiB
Diff

From efb082580161b889b88e5351ba25a1084ab618f1 Mon Sep 17 00:00:00 2001
From: Tux <write@imaginarycode.com>
Date: Tue, 25 Oct 2016 12:34:41 -0400
Subject: [PATCH] Validate that chat messages are non-blank
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 a667623b..d93d8851 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
@@ -146,6 +146,7 @@ public class UpstreamBridge extends PacketHandler
@Override
public void handle(Chat chat) throws Exception
{
+ boolean empty = true;
for ( int index = 0, length = chat.getMessage().length(); index < length; index++ )
{
char c = chat.getMessage().charAt( index );
@@ -154,8 +155,11 @@ public class UpstreamBridge extends PacketHandler
{
con.disconnect( bungee.getTranslation( "illegal_chat_characters", String.format( "\\u%04x", (int) c ) ) );
throw CancelSendSignal.INSTANCE;
+ } else if (empty && !Character.isWhitespace(c)) {
+ empty = false;
}
}
+ Preconditions.checkArgument(!empty, "Chat message is empty");
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.getMessage() );
if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
--
2.30.1 (Apple Git-130)