2023-11-04 02:12:26 +01:00
|
|
|
From 88834135061418ae8c007a335e2c0e5772f52ce5 Mon Sep 17 00:00:00 2001
|
2016-05-28 18:34:39 +02:00
|
|
|
From: Tux <write@imaginarycode.com>
|
2016-10-25 18:57:11 +02:00
|
|
|
Date: Tue, 25 Oct 2016 12:34:41 -0400
|
2016-05-28 18:34:39 +02:00
|
|
|
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
|
2023-11-04 02:12:26 +01:00
|
|
|
index 6acbf7bf..05e3bd21 100644
|
2016-05-28 18:34:39 +02:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
|
2023-11-04 02:12:26 +01:00
|
|
|
@@ -199,6 +199,7 @@ public class UpstreamBridge extends PacketHandler
|
2022-06-07 19:12:20 +02:00
|
|
|
|
|
|
|
private String handleChat(String message)
|
2016-05-28 18:34:39 +02:00
|
|
|
{
|
2021-07-03 01:00:48 +02:00
|
|
|
+ boolean empty = true;
|
2022-06-07 19:12:20 +02:00
|
|
|
for ( int index = 0, length = message.length(); index < length; index++ )
|
2021-07-03 01:00:48 +02:00
|
|
|
{
|
2022-06-07 19:12:20 +02:00
|
|
|
char c = message.charAt( index );
|
2023-11-04 02:12:26 +01:00
|
|
|
@@ -206,8 +207,14 @@ public class UpstreamBridge extends PacketHandler
|
2021-07-03 01:00:48 +02:00
|
|
|
{
|
2021-09-29 04:37:21 +02:00
|
|
|
con.disconnect( bungee.getTranslation( "illegal_chat_characters", Util.unicode( c ) ) );
|
2021-07-03 01:00:48 +02:00
|
|
|
throw CancelSendSignal.INSTANCE;
|
|
|
|
+ } else if (empty && !Character.isWhitespace(c)) {
|
|
|
|
+ empty = false;
|
|
|
|
}
|
|
|
|
}
|
2023-03-31 21:10:50 +02:00
|
|
|
+ if (empty) {
|
|
|
|
+ con.disconnect("Chat message is empty");
|
|
|
|
+ throw CancelSendSignal.INSTANCE;
|
|
|
|
+ }
|
2016-05-28 18:34:39 +02:00
|
|
|
|
2022-06-07 19:12:20 +02:00
|
|
|
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), message );
|
2016-11-01 16:51:42 +01:00
|
|
|
if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
|
2016-05-28 18:34:39 +02:00
|
|
|
--
|
2023-11-04 02:12:26 +01:00
|
|
|
2.42.1
|
2016-05-28 18:34:39 +02:00
|
|
|
|