Waterfall/BungeeCord-Patches/0023-Validate-that-chat-messages-are-non-blank.patch
2022-06-07 18:12:20 +01:00

34 lines
1.4 KiB
Diff

From ef16549d09c6a26772a904c40709b6a5edfd020c 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 58736e6f..b9a4b03c 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
@@ -173,6 +173,7 @@ public class UpstreamBridge extends PacketHandler
private String handleChat(String message)
{
+ boolean empty = true;
for ( int index = 0, length = message.length(); index < length; index++ )
{
char c = message.charAt( index );
@@ -180,8 +181,11 @@ public class UpstreamBridge extends PacketHandler
{
con.disconnect( bungee.getTranslation( "illegal_chat_characters", Util.unicode( 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(), message );
if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
--
2.35.3