13
0
geforkt von Mirrors/Velocity

Add cleanServerName to VelocityConfiguration to remove quotes and other unforeseen characters from server names before registration

Dieser Commit ist enthalten in:
Crypnotic 2020-02-09 13:40:15 -06:00 committet von Andrew Steinborn
Ursprung 98b03376e5
Commit d4e51e2d07

Datei anzeigen

@ -508,7 +508,7 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
Map<String, String> servers = new HashMap<>();
for (Map.Entry<String, Object> entry : toml.entrySet()) {
if (entry.getValue() instanceof String) {
servers.put(entry.getKey(), (String) entry.getValue());
servers.put(cleanServerName(entry.getKey()), (String) entry.getValue());
} else {
if (!entry.getKey().equalsIgnoreCase("try")) {
throw new IllegalArgumentException(
@ -542,6 +542,19 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
this.attemptConnectionOrder = attemptConnectionOrder;
}
/**
* TOML requires keys to match a regex of {@code [A-Za-z0-9_-]} unless it is wrapped in
* quotes; however, the TOML parser returns the key with the quotes so we need to clean the
* server name before we pass it onto server registration to keep proper server name behavior.
*
* @param name the server name to clean
*
* @return the cleaned server name
*/
private String cleanServerName(String name) {
return name.replace("\"", "");
}
@Override
public String toString() {
return "Servers{"