Add safe-usermap-names option to control usermap key sanitisation

This is necessary to stop players with Chinese characters in their username losing their balances.
This commit is contained in:
md678685 2019-05-30 18:50:51 +01:00
parent e9833d1cd2
commit c97918df24
4 changed files with 25 additions and 7 deletions

View file

@ -326,4 +326,6 @@ public interface ISettings extends IConf {
boolean isForceEnableRecipe(); boolean isForceEnableRecipe();
boolean allowOldIdSigns(); boolean allowOldIdSigns();
boolean isSafeUsermap();
} }

View file

@ -543,6 +543,7 @@ public class Settings implements net.ess3.api.ISettings {
itemDbType = _getItemDbType(); itemDbType = _getItemDbType();
forceEnableRecipe = _isForceEnableRecipe(); forceEnableRecipe = _isForceEnableRecipe();
allowOldIdSigns = _allowOldIdSigns(); allowOldIdSigns = _allowOldIdSigns();
isSafeUsermap = _isSafeUsermap();
} }
void _lateLoadItemSpawnBlacklist() { void _lateLoadItemSpawnBlacklist() {
@ -1540,4 +1541,15 @@ public class Settings implements net.ess3.api.ISettings {
public boolean allowOldIdSigns() { public boolean allowOldIdSigns() {
return allowOldIdSigns; return allowOldIdSigns;
} }
private boolean isSafeUsermap;
private boolean _isSafeUsermap() {
return config.getBoolean("safe-usermap-names", true);
}
@Override
public boolean isSafeUsermap() {
return isSafeUsermap;
}
} }

View file

@ -123,7 +123,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
if (uuid != null) { if (uuid != null) {
keys.add(uuid); keys.add(uuid);
if (name != null && name.length() > 0) { if (name != null && name.length() > 0) {
final String keyName = StringUtil.safeString(name); final String keyName = ess.getSettings().isSafeUsermap() ? StringUtil.safeString(name) : name;
if (!names.containsKey(keyName)) { if (!names.containsKey(keyName)) {
names.put(keyName, uuid); names.put(keyName, uuid);
uuidMap.writeUUIDMap(); uuidMap.writeUUIDMap();

View file

@ -281,6 +281,12 @@ player-commands:
- worth - worth
- xmpp - xmpp
# Use this option to force superperms-based permissions handler regardless of detected installed perms plugin.
# This is useful if you want superperms-based permissions (with wildcards) for custom permissions plugins.
# If you wish to use EssentialsX's built-in permissions using the `player-commands` section above, set this to false.
# Default is true.
use-bukkit-permissions: true
# When this option is enabled, one-time use kits (ie. delay < 0) will be # When this option is enabled, one-time use kits (ie. delay < 0) will be
# removed from the /kit list when a player can no longer use it # removed from the /kit list when a player can no longer use it
skip-used-one-time-kits-from-kit-list: false skip-used-one-time-kits-from-kit-list: false
@ -553,6 +559,10 @@ allow-direct-hat: true
# This doesn't affect running the command from the console, where a world is always required. # This doesn't affect running the command from the console, where a world is always required.
allow-world-in-broadcastworld: true allow-world-in-broadcastworld: true
# Should the usermap try to sanitise usernames before saving them?
# You should only change this to false if you use Minecraft China.
safe-usermap-names: true
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | EssentialsHome | # # | EssentialsHome | #
@ -627,12 +637,6 @@ min-money: -10000
# Enable this to log all interactions with trade/buy/sell signs and sell command. # Enable this to log all interactions with trade/buy/sell signs and sell command.
economy-log-enabled: false economy-log-enabled: false
# Use this option to force superperms-based permissions handler regardless of detected installed perms plugin.
# This is useful if you want superperms-based permissions (with wildcards) for custom permissions plugins.
# If you wish to use EssentialsX' built-in permissions using the `player-commands` section above, set this to false.
# Default is true.
use-bukkit-permissions: true
# Minimum acceptable amount to be used in /pay. # Minimum acceptable amount to be used in /pay.
minimum-pay-amount: 0.001 minimum-pay-amount: 0.001