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
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;
@@ -309,7 +310,7 @@ public class MySQL extends AbstractSqlDataSource {
String sql = "SELECT * FROM " + tableName + " WHERE " + col.NAME + "=?;";
PlayerAuth auth;
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
pst.setString(1, user.toLowerCase());
pst.setString(1, user.toLowerCase(Locale.ROOT));
try (ResultSet rs = pst.executeQuery()) {
if (rs.next()) {
int id = rs.getInt(col.ID);
@@ -377,11 +378,11 @@ public class MySQL extends AbstractSqlDataSource {
@Override
public boolean removeAuth(String user) {
user = user.toLowerCase();
user = user.toLowerCase(Locale.ROOT);
String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;";
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
sqlExtension.removeAuth(user, con);
pst.setString(1, user.toLowerCase());
pst.setString(1, user.toLowerCase(Locale.ROOT));
pst.executeUpdate();
return true;
} catch (SQLException ex) {
@@ -402,7 +403,7 @@ public class MySQL extends AbstractSqlDataSource {
String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;";
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
for (String name : toPurge) {
pst.setString(1, name.toLowerCase());
pst.setString(1, name.toLowerCase(Locale.ROOT));
pst.executeUpdate();
}
} catch (SQLException ex) {
@@ -470,7 +471,7 @@ public class MySQL extends AbstractSqlDataSource {
String sql = "UPDATE " + tableName + " SET " + col.TOTP_KEY + " = ? WHERE " + col.NAME + " = ?";
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
pst.setString(1, totpKey);
pst.setString(2, user.toLowerCase());
pst.setString(2, user.toLowerCase(Locale.ROOT));
pst.executeUpdate();
return true;
} catch (SQLException e) {