Waterfall/BungeeCord-Patches/0023-Validate-that-chat-messages-are-non-blank.patch

37 lines
1.5 KiB
Diff
Raw Normal View History

From e497a697d54e977d9ee969852cd84011c70bf435 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 c30093d7..7fb79bfd 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
@@ -188,6 +188,7 @@ public class UpstreamBridge extends PacketHandler
2022-06-07 19:12:20 +02:00
private String handleChat(String message)
{
+ boolean empty = true;
2022-06-07 19:12:20 +02:00
for ( int index = 0, length = message.length(); index < length; index++ )
{
2022-06-07 19:12:20 +02:00
char c = message.charAt( index );
@@ -195,8 +196,14 @@ public class UpstreamBridge extends PacketHandler
{
2021-09-29 04:37:21 +02:00
con.disconnect( bungee.getTranslation( "illegal_chat_characters", Util.unicode( c ) ) );
throw CancelSendSignal.INSTANCE;
+ } else if (empty && !Character.isWhitespace(c)) {
+ empty = false;
}
}
+ if (empty) {
+ con.disconnect("Chat message is empty");
+ throw CancelSendSignal.INSTANCE;
+ }
2022-06-07 19:12:20 +02:00
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), message );
if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
--
2.40.0