Fix channel name validation in 1.13 to 1.12.2 protocol (#2701)

Closes #2187
This commit is contained in:
Gero 2021-10-03 12:12:49 +02:00 committed by GitHub
parent e64a0fb62e
commit a0f26f1ca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,15 +137,17 @@ public class MappingData extends MappingDataBase {
return null; // Not valid
}
int separatorIndex = newId.indexOf(':');
// Vanilla parses ``:`` and ```` as ``minecraft:`` (also ensure there's enough space)
if ((separatorIndex == -1 || separatorIndex == 0) && newId.length() <= 10) {
// Vanilla parses an empty and a missing namespace as the minecraft namespace
if (separatorIndex == -1) {
newId = "minecraft:" + newId;
} else if (separatorIndex == 0) {
newId = "minecraft" + newId;
}
return newId;
}
public static boolean isValid1_13Channel(String channelId) {
return channelId.matches("([0-9a-z_.-]+):([0-9a-z_/.-]+)");
return channelId.matches("([0-9a-z_.-]+:)?[0-9a-z_/.-]+");
}
private void loadTags(Map<String, Integer[]> output, JsonObject newTags) {