forked from kaboomserver/extras
fix: highly experimental (and hacky!) patch for kick exploit
This commit is contained in:
parent
39feb26c93
commit
a58ef649cf
1 changed files with 15 additions and 0 deletions
|
@ -38,6 +38,19 @@ public final class ServerCommand implements Listener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean checkValidUTF8(final String component) {
|
||||||
|
int len = component.length();
|
||||||
|
|
||||||
|
for (int i = 0; i < component.length(); i++) {
|
||||||
|
int c = component.charAt(i);
|
||||||
|
if (c == 0 || c >= 128) {
|
||||||
|
len += c >= 2048 ? 2 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return len <= 65535;
|
||||||
|
}
|
||||||
|
|
||||||
private static String checkSelectors(final String[] arr) {
|
private static String checkSelectors(final String[] arr) {
|
||||||
final String[] args = Arrays.copyOfRange(arr, 1, arr.length);
|
final String[] args = Arrays.copyOfRange(arr, 1, arr.length);
|
||||||
final String str = String.join(" ", args);
|
final String str = String.join(" ", args);
|
||||||
|
@ -77,6 +90,8 @@ public final class ServerCommand implements Listener {
|
||||||
commandName = "/" + arr[1].toLowerCase();
|
commandName = "/" + arr[1].toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!checkValidUTF8(command)) return "cancel";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch (commandName) {
|
switch (commandName) {
|
||||||
case "/minecraft:execute", "/execute" -> {
|
case "/minecraft:execute", "/execute" -> {
|
||||||
|
|
Loading…
Reference in a new issue