mirror of
https://github.com/kaboomserver/extras.git
synced 2025-02-14 05:01:19 +00:00
Patch title unicode kick exploit (#293)
This commit is contained in:
parent
97b0177d08
commit
a3ea2d7498
1 changed files with 23 additions and 2 deletions
|
@ -77,7 +77,7 @@ public final class ServerCommand implements Listener {
|
||||||
return String.join(" ", arr);
|
return String.join(" ", arr);
|
||||||
}
|
}
|
||||||
} else if ("title".equalsIgnoreCase(arr[i + 1])) {
|
} else if ("title".equalsIgnoreCase(arr[i + 1])) {
|
||||||
if (command.contains("selector")) {
|
if (parseCharCodes(command).contains("selector")) {
|
||||||
return "cancel";
|
return "cancel";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ public final class ServerCommand implements Listener {
|
||||||
break;
|
break;
|
||||||
case "/minecraft:title":
|
case "/minecraft:title":
|
||||||
case "/title":
|
case "/title":
|
||||||
if (command.contains("selector")) {
|
if (parseCharCodes(command).contains("selector")) {
|
||||||
return "cancel";
|
return "cancel";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -199,4 +199,25 @@ public final class ServerCommand implements Listener {
|
||||||
|
|
||||||
System.out.println("Console command: " + command);
|
System.out.println("Console command: " + command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String parseCharCodes(final String input) {
|
||||||
|
if (input.contains("\\u")) {
|
||||||
|
StringBuilder output = new StringBuilder();
|
||||||
|
String[] split = input.split("\\\\u");
|
||||||
|
int index = 0;
|
||||||
|
for (String item:split) {
|
||||||
|
if (index == 0) {
|
||||||
|
output.append(item);
|
||||||
|
} else {
|
||||||
|
String charCode = item.substring(0, 4);
|
||||||
|
output.append((char) Integer.parseInt(charCode, 16));
|
||||||
|
output.append(item.substring(4));
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return output.toString();
|
||||||
|
} else {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue