From e69a021c7159ed9711b8988c2ccbf87671a21b14 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Fri, 3 Jul 2020 02:00:58 +0400 Subject: [PATCH] Fixed missing locale param in string operations (#4634) --- .../main/java/mage/client/dialog/PickCheckBoxDialog.java | 4 ++-- Mage.Sets/src/mage/cards/j/JeganthaTheWellspring.java | 4 ++-- Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java | 2 +- Mage.Sets/src/mage/cards/v/VivienMonstersAdvocate.java | 3 ++- .../src/test/java/mage/verify/VerifyCardDataTest.java | 2 +- .../common/delayed/ReflexiveTriggeredAbility.java | 4 +++- .../mage/abilities/effects/common/ChooseColorEffect.java | 4 +++- .../abilities/effects/common/RollPlanarDieEffect.java | 3 ++- .../common/counter/AddCounterChoiceSourceEffect.java | 4 +++- .../mage/abilities/keyword/BandsWithOtherAbility.java | 4 +++- .../java/mage/abilities/meta/OrTriggeredAbility.java | 9 +++++---- Mage/src/main/java/mage/cards/decks/DeckFormatsTest.java | 5 +++-- 12 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/dialog/PickCheckBoxDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PickCheckBoxDialog.java index 4f41afc930..584d5b5aa3 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PickCheckBoxDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/PickCheckBoxDialog.java @@ -230,12 +230,12 @@ public class PickCheckBoxDialog extends MageDialog { if (filter == null) { filter = ""; } - filter = filter.toLowerCase(); + filter = filter.toLowerCase(Locale.ENGLISH); this.dataModel.clear(); this.m_dataModel.clear(); for (KeyValueItem item : this.allItems) { - if (!choice.isSearchEnabled() || item.Value.toLowerCase().contains(filter)) { + if (!choice.isSearchEnabled() || item.Value.toLowerCase(Locale.ENGLISH).contains(filter)) { this.dataModel.addElement(item); this.m_dataModel.addElement(item.getObjectValue()); } diff --git a/Mage.Sets/src/mage/cards/j/JeganthaTheWellspring.java b/Mage.Sets/src/mage/cards/j/JeganthaTheWellspring.java index f173e10816..2a8a274919 100644 --- a/Mage.Sets/src/mage/cards/j/JeganthaTheWellspring.java +++ b/Mage.Sets/src/mage/cards/j/JeganthaTheWellspring.java @@ -119,7 +119,7 @@ class JeganthaTheWellspringManaCondition extends ManaCondition { private final String manaSymbol; JeganthaTheWellspringManaCondition(String manaSymbol) { - this.manaSymbol = manaSymbol.toLowerCase(); + this.manaSymbol = manaSymbol.toLowerCase(Locale.ENGLISH); } @Override @@ -132,6 +132,6 @@ class JeganthaTheWellspringManaCondition extends ManaCondition { .getUnpaid() .getText() .split("[\\}\\{]") - ).map(String::toLowerCase).anyMatch(s -> s.contains(manaSymbol)); + ).map(s -> s.toLowerCase(Locale.ENGLISH)).anyMatch(s -> s.contains(manaSymbol)); } } diff --git a/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java b/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java index d8dd2294d6..49ac10a33b 100644 --- a/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java +++ b/Mage.Sets/src/mage/cards/m/MythosOfSnapdax.java @@ -95,7 +95,7 @@ class MythosOfSnapdaxEffect extends OneShotEffect { for (Player player : playerList) { for (CardType cardType : cardTypes) { String message = cardType.toString().equals("Artifact") ? "an " : "a "; - message += cardType.toString().toLowerCase(); + message += cardType.toString().toLowerCase(Locale.ENGLISH); message += (conditionMet && player != controller) ? " controlled by " + player.getName() : " you control"; FilterPermanent filter = new FilterNonlandPermanent(message); filter.add(cardType.getPredicate()); diff --git a/Mage.Sets/src/mage/cards/v/VivienMonstersAdvocate.java b/Mage.Sets/src/mage/cards/v/VivienMonstersAdvocate.java index 365b7f5416..117b236707 100644 --- a/Mage.Sets/src/mage/cards/v/VivienMonstersAdvocate.java +++ b/Mage.Sets/src/mage/cards/v/VivienMonstersAdvocate.java @@ -29,6 +29,7 @@ import mage.players.Player; import mage.target.common.TargetCardInLibrary; import java.util.Arrays; +import java.util.Locale; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -110,7 +111,7 @@ class VivienMonstersAdvocateTokenEffect extends OneShotEffect { player.choose(outcome, choice, game); String chosen = choice.getChoice(); if (chosen != null) { - permanent.addCounters(CounterType.findByName(chosen.toLowerCase()).createInstance(), source, game); + permanent.addCounters(CounterType.findByName(chosen.toLowerCase(Locale.ENGLISH)).createInstance(), source, game); } } return true; diff --git a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java index 7aac72e181..b421adace4 100644 --- a/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java +++ b/Mage.Verify/src/test/java/mage/verify/VerifyCardDataTest.java @@ -331,7 +331,7 @@ public class VerifyCardDataTest { // replace codes for aliases String searchSet = MtgJson.mtgJsonToXMageCodes.getOrDefault(refSet.code, refSet.code); - ExpansionSet mageSet = Sets.findSet(searchSet.toUpperCase()); + ExpansionSet mageSet = Sets.findSet(searchSet.toUpperCase(Locale.ENGLISH)); if (mageSet == null) { totalMissingSets = totalMissingSets + 1; totalMissingCards = totalMissingCards + refSet.cards.size(); diff --git a/Mage/src/main/java/mage/abilities/common/delayed/ReflexiveTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/delayed/ReflexiveTriggeredAbility.java index 08fd88c78f..e8202aa834 100644 --- a/Mage/src/main/java/mage/abilities/common/delayed/ReflexiveTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/delayed/ReflexiveTriggeredAbility.java @@ -6,6 +6,8 @@ import mage.constants.Duration; import mage.game.Game; import mage.game.events.GameEvent; +import java.util.Locale; + /** * @author TheElk801 */ @@ -36,7 +38,7 @@ public class ReflexiveTriggeredAbility extends DelayedTriggeredAbility { @Override public String getRule() { - return text.substring(0, 1).toUpperCase() + text.substring(1) + '.'; + return text.substring(0, 1).toUpperCase(Locale.ENGLISH) + text.substring(1) + '.'; } public String getText() { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java index 72f5fc686c..ddda5e3e10 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseColorEffect.java @@ -11,6 +11,8 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.util.CardUtil; +import java.util.Locale; + /** * @author Plopman */ @@ -25,7 +27,7 @@ public class ChooseColorEffect extends OneShotEffect { public ChooseColorEffect(Outcome outcome, String exceptColor) { super(outcome); this.exceptColor = exceptColor; - staticText = "choose a color" + (exceptColor != null ? " other than " + exceptColor.toLowerCase() : ""); + staticText = "choose a color" + (exceptColor != null ? " other than " + exceptColor.toLowerCase(Locale.ENGLISH) : ""); } public ChooseColorEffect(final ChooseColorEffect effect) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/RollPlanarDieEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RollPlanarDieEffect.java index 32a0ac6cb1..dbfd982bb9 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/RollPlanarDieEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/RollPlanarDieEffect.java @@ -17,6 +17,7 @@ import mage.target.Target; import mage.target.targetpointer.FixedTarget; import java.util.List; +import java.util.Locale; import java.util.stream.Collectors; /** @@ -150,7 +151,7 @@ public class RollPlanarDieEffect extends OneShotEffect { if (effect != null) { try { String emode = effect.getText(mode); - emode = emode.substring(0, 1).toLowerCase() + emode.substring(1); + emode = emode.substring(0, 1).toLowerCase(Locale.ENGLISH) + emode.substring(1); sb.append(emode); } catch (Exception e) { sb.append("perform the CHAOS action"); diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCounterChoiceSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCounterChoiceSourceEffect.java index a62cb8145c..f181e21aa8 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCounterChoiceSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCounterChoiceSourceEffect.java @@ -9,6 +9,8 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; +import java.util.Locale; + /** * @author TheElk801 */ @@ -50,7 +52,7 @@ public class AddCounterChoiceSourceEffect extends OneShotEffect { } private static final String cap(String string) { - return string != null ? string.substring(0, 1).toUpperCase() + string.substring(1) : null; + return string != null ? string.substring(0, 1).toUpperCase(Locale.ENGLISH) + string.substring(1) : null; } @Override diff --git a/Mage/src/main/java/mage/abilities/keyword/BandsWithOtherAbility.java b/Mage/src/main/java/mage/abilities/keyword/BandsWithOtherAbility.java index 9716450908..28db7a4b53 100644 --- a/Mage/src/main/java/mage/abilities/keyword/BandsWithOtherAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/BandsWithOtherAbility.java @@ -6,6 +6,8 @@ import mage.constants.SubType; import mage.constants.SuperType; import mage.constants.Zone; +import java.util.Locale; + /** * * @author L_J @@ -69,7 +71,7 @@ public class BandsWithOtherAbility extends StaticAbility { if (subtype != null) { return sb.append(' ').append(subtype.getDescription()).append('s').toString(); } else if (supertype != null) { - return sb.append(' ').append(supertype.toString().toLowerCase()).append(" creatures").toString(); + return sb.append(' ').append(supertype.toString().toLowerCase(Locale.ENGLISH)).append(" creatures").toString(); } else if (bandingName != null) { return sb.append(" creatures named ").append(bandingName).toString(); } diff --git a/Mage/src/main/java/mage/abilities/meta/OrTriggeredAbility.java b/Mage/src/main/java/mage/abilities/meta/OrTriggeredAbility.java index 0a4a17cb4c..000631583a 100644 --- a/Mage/src/main/java/mage/abilities/meta/OrTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/meta/OrTriggeredAbility.java @@ -2,6 +2,7 @@ package mage.abilities.meta; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.UUID; import mage.abilities.TriggeredAbility; import mage.abilities.TriggeredAbilityImpl; @@ -86,15 +87,15 @@ public class OrTriggeredAbility extends TriggeredAbilityImpl { } StringBuilder sb = new StringBuilder(); if (triggeredAbilities[0].getRule().length() > 0) { - sb.append(triggeredAbilities[0].getRule().substring(0, 1).toUpperCase()) - .append(triggeredAbilities[0].getRule().substring(1).toLowerCase()); + sb.append(triggeredAbilities[0].getRule().substring(0, 1).toUpperCase(Locale.ENGLISH)) + .append(triggeredAbilities[0].getRule().substring(1).toLowerCase(Locale.ENGLISH)); } for (int i = 1; i < (triggeredAbilities.length - 1); i++) { - sb.append(triggeredAbilities[i].getRule().toLowerCase()); + sb.append(triggeredAbilities[i].getRule().toLowerCase(Locale.ENGLISH)); } - sb.append(" or ").append(triggeredAbilities[triggeredAbilities.length - 1].getRule().toLowerCase()); + sb.append(" or ").append(triggeredAbilities[triggeredAbilities.length - 1].getRule().toLowerCase(Locale.ENGLISH)); return sb.toString() + super.getRule(); } diff --git a/Mage/src/main/java/mage/cards/decks/DeckFormatsTest.java b/Mage/src/main/java/mage/cards/decks/DeckFormatsTest.java index 2b0e71e502..6dfe1d612f 100644 --- a/Mage/src/main/java/mage/cards/decks/DeckFormatsTest.java +++ b/Mage/src/main/java/mage/cards/decks/DeckFormatsTest.java @@ -4,6 +4,7 @@ import org.junit.Assert; import org.junit.Test; import java.util.HashMap; +import java.util.Locale; import java.util.Map; /** @@ -23,8 +24,8 @@ public class DeckFormatsTest { } // 2. must work with files String fileName = "C:\\xmage\\deck" + "." + df.getExporter().getDefaultFileExt(); - Assert.assertTrue("Must support lower ext: " + df.getExporter().getDescription(), DeckFormats.getFormatForExtension(fileName.toLowerCase()).isPresent()); - Assert.assertTrue("Must support upper ext: " + df.getExporter().getDescription(), DeckFormats.getFormatForExtension(fileName.toUpperCase()).isPresent()); + Assert.assertTrue("Must support lower ext: " + df.getExporter().getDescription(), DeckFormats.getFormatForExtension(fileName.toLowerCase(Locale.ENGLISH)).isPresent()); + Assert.assertTrue("Must support upper ext: " + df.getExporter().getDescription(), DeckFormats.getFormatForExtension(fileName.toUpperCase(Locale.ENGLISH)).isPresent()); } // 3. wrong ext