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:
Gabriele C
2022-08-20 04:41:04 +02:00
parent c38e2aba28
commit 75b3a571e1
67 changed files with 217 additions and 143 deletions
@@ -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);