2016-11-01 16:51:42 +01:00
|
|
|
From 6160bd409a7759a460bddb26dae0dfc36a0680a4 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/io/github/waterfallmc/waterfall/StringUtil.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/StringUtil.java
|
|
|
|
new file mode 100644
|
2016-10-25 18:57:11 +02:00
|
|
|
index 0000000..d294dda
|
2016-05-28 18:34:39 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/StringUtil.java
|
|
|
|
@@ -0,0 +1,22 @@
|
|
|
|
+package io.github.waterfallmc.waterfall;
|
|
|
|
+
|
|
|
|
+import lombok.AccessLevel;
|
|
|
|
+import lombok.NoArgsConstructor;
|
|
|
|
+
|
|
|
|
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
|
|
+public class StringUtil {
|
|
|
|
+ public static boolean isBlank(String str) {
|
|
|
|
+ if (str.isEmpty()) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int l = str.length();
|
|
|
|
+ for (int i = 0; i < l; i++) {
|
|
|
|
+ if (!Character.isWhitespace(str.charAt(i))) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+}
|
2016-10-25 18:57:11 +02:00
|
|
|
\ No newline at end of file
|
2016-05-28 18:34:39 +02:00
|
|
|
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
|
2016-11-01 16:51:42 +01:00
|
|
|
index 417b2f7..3c3fd98 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
|
|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
package net.md_5.bungee.connection;
|
|
|
|
|
|
|
|
import com.google.common.base.Preconditions;
|
|
|
|
+import io.github.waterfallmc.waterfall.StringUtil;
|
2016-10-25 18:57:11 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2016-05-28 18:34:39 +02:00
|
|
|
import net.md_5.bungee.BungeeCord;
|
2016-11-01 16:51:42 +01:00
|
|
|
@@ -112,6 +113,7 @@ public class UpstreamBridge extends PacketHandler
|
2016-05-28 18:34:39 +02:00
|
|
|
public void handle(Chat chat) throws Exception
|
|
|
|
{
|
|
|
|
Preconditions.checkArgument( chat.getMessage().length() <= 100, "Chat message too long" ); // Mojang limit, check on updates
|
|
|
|
+ Preconditions.checkArgument(!StringUtil.isBlank(chat.getMessage()), "Chat message is empty");
|
|
|
|
|
2016-11-01 16:51:42 +01:00
|
|
|
ChatEvent chatEvent = new ChatEvent( con, con.getServer(), chat.getMessage() );
|
|
|
|
if ( !bungee.getPluginManager().callEvent( chatEvent ).isCancelled() )
|
2016-05-28 18:34:39 +02:00
|
|
|
--
|
2016-11-01 16:51:42 +01:00
|
|
|
2.10.0
|
2016-05-28 18:34:39 +02:00
|
|
|
|