1
0
mirror of https://github.com/DiscordSRV/Ascension.git synced 2025-02-16 01:41:26 +01:00

Block non-alphanumeric characters, underscores and dashes from sql table prefix

This commit is contained in:
Vankka 2023-10-15 23:13:17 +03:00
parent baf7e5027b
commit affa127906
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0

View File

@ -71,14 +71,19 @@ public abstract class SQLStorage implements Storage {
}
protected String tablePrefix() {
return discordSRV.connectionConfig().storage.sqlTablePrefix;
String tablePrefix = discordSRV.connectionConfig().storage.sqlTablePrefix;
if (!tablePrefix.matches("[\\w_-]*")) {
throw new IllegalStateException("SQL Table prefix may not contain non alphanumeric characters, dashes and underscores!");
}
return tablePrefix;
}
@Override
public void initialize() {
useConnection((CheckedConsumer<Connection>) connection -> createTables(
connection,
discordSRV.connectionConfig().storage.sqlTablePrefix
tablePrefix()
));
}