Merge pull request 'Fix Invalid Schem Names' (#153) from is_punished into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #153 Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
0e3544f730
@ -228,10 +228,14 @@ public class SchematicSelector {
|
||||
SWAnvilInv inv = new SWAnvilInv(player, Core.MESSAGE.parse("SCHEM_SELECTOR_CREATE_DIR_TITLE", player));
|
||||
inv.setItem(Material.CHEST);
|
||||
inv.setCallback(s -> {
|
||||
if(!SchematicNode.invalidSchemName(new String[] {s})) {
|
||||
if(injectable.onFolderCreate(this, s)) {
|
||||
SchematicNode.createSchematicDirectory(user.getId(), s, parent==null?0:parent.getId());
|
||||
openList(parent);
|
||||
}
|
||||
return;
|
||||
}
|
||||
player.closeInventory();
|
||||
});
|
||||
inv.open();
|
||||
}
|
||||
|
@ -604,4 +604,28 @@ public class SchematicNode {
|
||||
list.remove("//copy");
|
||||
return list;
|
||||
}
|
||||
|
||||
private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
|
||||
public static boolean invalidSchemName(String[] layers) {
|
||||
for (String layer : layers) {
|
||||
if (layer.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (layer.contains("/") ||
|
||||
layer.contains("\\") ||
|
||||
layer.contains("<") ||
|
||||
layer.contains(">") ||
|
||||
layer.contains("^") ||
|
||||
layer.contains("°") ||
|
||||
layer.contains("'") ||
|
||||
layer.contains("\"") ||
|
||||
layer.contains(" ")) {
|
||||
return true;
|
||||
}
|
||||
if(FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren