SPIGOT-7676: Enforce locale parameter in toLowerCase and toUpperCase method calls and always use root locale
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
@@ -67,8 +68,8 @@ public class SimpleCommandMap implements CommandMap {
|
||||
*/
|
||||
@Override
|
||||
public boolean register(@NotNull String label, @NotNull String fallbackPrefix, @NotNull Command command) {
|
||||
label = label.toLowerCase(java.util.Locale.ENGLISH).trim();
|
||||
fallbackPrefix = fallbackPrefix.toLowerCase(java.util.Locale.ENGLISH).trim();
|
||||
label = label.toLowerCase(Locale.ROOT).trim();
|
||||
fallbackPrefix = fallbackPrefix.toLowerCase(Locale.ROOT).trim();
|
||||
boolean registered = register(label, command, false, fallbackPrefix);
|
||||
|
||||
Iterator<String> iterator = command.getAliases().iterator();
|
||||
@@ -136,7 +137,7 @@ public class SimpleCommandMap implements CommandMap {
|
||||
return false;
|
||||
}
|
||||
|
||||
String sentCommandLabel = args[0].toLowerCase(java.util.Locale.ENGLISH);
|
||||
String sentCommandLabel = args[0].toLowerCase(Locale.ROOT);
|
||||
Command target = getCommand(sentCommandLabel);
|
||||
|
||||
if (target == null) {
|
||||
@@ -168,7 +169,7 @@ public class SimpleCommandMap implements CommandMap {
|
||||
@Override
|
||||
@Nullable
|
||||
public Command getCommand(@NotNull String name) {
|
||||
Command target = knownCommands.get(name.toLowerCase(java.util.Locale.ENGLISH));
|
||||
Command target = knownCommands.get(name.toLowerCase(Locale.ROOT));
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -272,9 +273,9 @@ public class SimpleCommandMap implements CommandMap {
|
||||
|
||||
// We register these as commands so they have absolute priority.
|
||||
if (targets.size() > 0) {
|
||||
knownCommands.put(alias.toLowerCase(java.util.Locale.ENGLISH), new FormattedCommandAlias(alias.toLowerCase(java.util.Locale.ENGLISH), targets.toArray(new String[targets.size()])));
|
||||
knownCommands.put(alias.toLowerCase(Locale.ROOT), new FormattedCommandAlias(alias.toLowerCase(Locale.ROOT), targets.toArray(new String[targets.size()])));
|
||||
} else {
|
||||
knownCommands.remove(alias.toLowerCase(java.util.Locale.ENGLISH));
|
||||
knownCommands.remove(alias.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -61,9 +62,9 @@ public class VersionCommand extends BukkitCommand {
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
pluginName = pluginName.toLowerCase(java.util.Locale.ENGLISH);
|
||||
pluginName = pluginName.toLowerCase(Locale.ROOT);
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (plugin.getName().toLowerCase(java.util.Locale.ENGLISH).contains(pluginName)) {
|
||||
if (plugin.getName().toLowerCase(Locale.ROOT).contains(pluginName)) {
|
||||
describeToSender(plugin, sender);
|
||||
found = true;
|
||||
}
|
||||
@@ -133,7 +134,7 @@ public class VersionCommand extends BukkitCommand {
|
||||
|
||||
if (args.length == 1) {
|
||||
List<String> completions = new ArrayList<String>();
|
||||
String toComplete = args[0].toLowerCase(java.util.Locale.ENGLISH);
|
||||
String toComplete = args[0].toLowerCase(Locale.ROOT);
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (StringUtil.startsWithIgnoreCase(plugin.getName(), toComplete)) {
|
||||
completions.add(plugin.getName());
|
||||
|
||||
Reference in New Issue
Block a user