Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
Fix statistic writing when sub-category contains apostrophes
Browse files Browse the repository at this point in the history
  • Loading branch information
PyvesB committed Oct 3, 2020
1 parent c6ff6a0 commit 39684df
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import org.apache.commons.lang3.StringUtils;

import com.hm.achievement.category.MultipleAchievements;
import com.hm.achievement.category.NormalAchievements;

Expand Down Expand Up @@ -92,7 +94,7 @@ private void addRequestsForMultipleCategory(List<String> batchedRequests, Multip
// Set flag before writing to database so that concurrent updates are not wrongly marked as consistent.
statistic.prepareDatabaseWrite();
UUID uuid = entry.getKey().getUUID();
String subcategory = entry.getKey().getSubcategory();
String subcategory = StringUtils.replace(entry.getKey().getSubcategory(), "'", "''");
if (databaseManager instanceof PostgreSQLDatabaseManager) {
batchedRequests.add("INSERT INTO " + databaseManager.getPrefix() + category.toDBName() + " VALUES ('"
+ uuid + "', '" + subcategory + "', " + statistic.getValue() + ") ON CONFLICT (playername, "
Expand Down

0 comments on commit 39684df

Please sign in to comment.