Always specify Locale on toLowerCase and toUpperCase usages, fixes AuthMe not working correctly on machines with turkish locale. ('I'.toLowerCase() => 'ı')
This commit is contained in:
@@ -11,6 +11,7 @@ import fr.xephi.authme.util.AtomicIntervalCounter;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE;
|
||||
@@ -176,7 +177,7 @@ public class AntiBotService implements SettingsDependent {
|
||||
* @return true if the given name has been kicked because of Antibot
|
||||
*/
|
||||
public boolean wasPlayerKicked(String name) {
|
||||
return antibotKicked.contains(name.toLowerCase());
|
||||
return antibotKicked.contains(name.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +187,7 @@ public class AntiBotService implements SettingsDependent {
|
||||
* @param name the name to add
|
||||
*/
|
||||
public void addPlayerKick(String name) {
|
||||
antibotKicked.addIfAbsent(name.toLowerCase());
|
||||
antibotKicked.addIfAbsent(name.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public enum AntiBotStatus {
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Locale;
|
||||
|
||||
import static fr.xephi.authme.util.Utils.logAndSendMessage;
|
||||
import static fr.xephi.authme.util.Utils.logAndSendWarning;
|
||||
@@ -151,7 +152,7 @@ public class BackupService {
|
||||
* @return True if the path is correct, false if it is incorrect or the OS is not Windows
|
||||
*/
|
||||
private boolean useWindowsCommand(String windowsPath) {
|
||||
String isWin = System.getProperty("os.name").toLowerCase();
|
||||
String isWin = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
||||
if (isWin.contains("win")) {
|
||||
if (new File(windowsPath + "\\bin\\mysqldump.exe").exists()) {
|
||||
return true;
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static fr.xephi.authme.settings.properties.EmailSettings.RECOVERY_PASSWORD_LENGTH;
|
||||
@@ -76,7 +77,7 @@ public class PasswordRecoveryService implements Reloadable, HasCleanup {
|
||||
boolean couldSendMail = emailService.sendRecoveryCode(player.getName(), email, recoveryCode);
|
||||
if (couldSendMail) {
|
||||
commonService.send(player, MessageKey.RECOVERY_CODE_SENT);
|
||||
emailCooldown.add(player.getName().toLowerCase());
|
||||
emailCooldown.add(player.getName().toLowerCase(Locale.ROOT));
|
||||
} else {
|
||||
commonService.send(player, MessageKey.EMAIL_SEND_FAILURE);
|
||||
}
|
||||
@@ -104,7 +105,7 @@ public class PasswordRecoveryService implements Reloadable, HasCleanup {
|
||||
boolean couldSendMail = emailService.sendPasswordMail(name, email, thePass);
|
||||
if (couldSendMail) {
|
||||
commonService.send(player, MessageKey.RECOVERY_EMAIL_SENT_MESSAGE);
|
||||
emailCooldown.add(player.getName().toLowerCase());
|
||||
emailCooldown.add(player.getName().toLowerCase(Locale.ROOT));
|
||||
} else {
|
||||
commonService.send(player, MessageKey.EMAIL_SEND_FAILURE);
|
||||
}
|
||||
@@ -141,7 +142,7 @@ public class PasswordRecoveryService implements Reloadable, HasCleanup {
|
||||
* @return True if the player is not on cooldown.
|
||||
*/
|
||||
private boolean checkEmailCooldown(Player player) {
|
||||
Duration waitDuration = emailCooldown.getExpiration(player.getName().toLowerCase());
|
||||
Duration waitDuration = emailCooldown.getExpiration(player.getName().toLowerCase(Locale.ROOT));
|
||||
if (waitDuration.getDuration() > 0) {
|
||||
String durationText = messages.formatDuration(waitDuration);
|
||||
messages.send(player, MessageKey.EMAIL_COOLDOWN_ERROR, durationText);
|
||||
|
||||
@@ -25,6 +25,7 @@ import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -69,7 +70,7 @@ public class ValidationService implements Reloadable {
|
||||
* @return the validation result
|
||||
*/
|
||||
public ValidationResult validatePassword(String password, String username) {
|
||||
String passLow = password.toLowerCase();
|
||||
String passLow = password.toLowerCase(Locale.ROOT);
|
||||
if (!passwordRegex.matcher(passLow).matches()) {
|
||||
return new ValidationResult(MessageKey.PASSWORD_CHARACTERS_ERROR, passwordRegex.pattern());
|
||||
} else if (passLow.equalsIgnoreCase(username)) {
|
||||
@@ -139,7 +140,7 @@ public class ValidationService implements Reloadable {
|
||||
* @return true if unrestricted, false otherwise
|
||||
*/
|
||||
public boolean isUnrestricted(String name) {
|
||||
return settings.getProperty(RestrictionSettings.UNRESTRICTED_NAMES).contains(name.toLowerCase());
|
||||
return settings.getProperty(RestrictionSettings.UNRESTRICTED_NAMES).contains(name.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +150,7 @@ public class ValidationService implements Reloadable {
|
||||
* @return true if the player may join, false if the player does not satisfy the name restrictions
|
||||
*/
|
||||
public boolean fulfillsNameRestrictions(Player player) {
|
||||
Collection<String> restrictions = restrictedNames.get(player.getName().toLowerCase());
|
||||
Collection<String> restrictions = restrictedNames.get(player.getName().toLowerCase(Locale.ROOT));
|
||||
if (Utils.isCollectionEmpty(restrictions)) {
|
||||
return true;
|
||||
}
|
||||
@@ -212,7 +213,7 @@ public class ValidationService implements Reloadable {
|
||||
for (String restriction : configuredRestrictions) {
|
||||
if (isInsideString(';', restriction)) {
|
||||
String[] data = restriction.split(";");
|
||||
restrictions.put(data[0].toLowerCase(), data[1]);
|
||||
restrictions.put(data[0].toLowerCase(Locale.ROOT), data[1]);
|
||||
} else {
|
||||
logger.warning("Restricted user rule must have a ';' separating name from restriction,"
|
||||
+ " but found: '" + restriction + "'");
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.Messenger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Locale;
|
||||
|
||||
public class BungeeSender implements SettingsDependent {
|
||||
|
||||
@@ -103,9 +104,9 @@ public class BungeeSender implements SettingsDependent {
|
||||
return;
|
||||
}
|
||||
if (type.isBroadcast()) {
|
||||
sendForwardedBungeecordMessage(player, "AuthMe.v2.Broadcast", type.getId(), player.getName().toLowerCase());
|
||||
sendForwardedBungeecordMessage(player, "AuthMe.v2.Broadcast", type.getId(), player.getName().toLowerCase(Locale.ROOT));
|
||||
} else {
|
||||
sendBungeecordMessage(player, "AuthMe.v2", type.getId(), player.getName().toLowerCase());
|
||||
sendBungeecordMessage(player, "AuthMe.v2", type.getId(), player.getName().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user