From: Jim Procter Date: Mon, 10 Aug 2020 14:10:35 +0000 (+0100) Subject: JAL-3691 toUpperCase(Locale.ROOT) for all standard file format operations X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fcherry-pick%2FJAL-3691_to_2.11.2_localeSafeFileImport;p=jalview.git JAL-3691 toUpperCase(Locale.ROOT) for all standard file format operations --- diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index c08c84e..e625f8e 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -28,6 +28,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; @@ -346,7 +347,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI String line; while ((line = nextLine()) != null) { - if (line.toUpperCase().startsWith(ENDFILTERS)) + // TODO: use .trim().equalsIgnoreCase here instead ? + if (line.toUpperCase(Locale.ROOT).startsWith(ENDFILTERS)) { return; } diff --git a/src/jalview/io/FileFormats.java b/src/jalview/io/FileFormats.java index aadcdb9..de83e9b 100644 --- a/src/jalview/io/FileFormats.java +++ b/src/jalview/io/FileFormats.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -102,7 +103,7 @@ public class FileFormats protected void registerFileFormat(FileFormatI format, boolean isIdentifiable) { - String name = format.getName().toUpperCase(); + String name = format.getName().toUpperCase(Locale.ROOT); if (formats.containsKey(name)) { System.err.println("Overwriting file format: " + format.getName()); @@ -121,7 +122,7 @@ public class FileFormats */ public void deregisterFileFormat(String name) { - FileFormatI ff = formats.remove(name.toUpperCase()); + FileFormatI ff = formats.remove(name.toUpperCase(Locale.ROOT)); identifiable.remove(ff); } @@ -174,7 +175,7 @@ public class FileFormats */ public FileFormatI forName(String format) { - return format == null ? null : formats.get(format.toUpperCase()); + return format == null ? null : formats.get(format.toUpperCase(Locale.ROOT)); } /** diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index 85cf48a..4252268 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -34,6 +34,7 @@ import jalview.util.Comparison; import java.io.File; import java.io.IOException; +import java.util.Locale; /** * Additional formatting methods used by the application in a number of places. @@ -162,7 +163,7 @@ public class FormatAdapter extends AppletFormatAdapter public boolean getCacheSuffixDefault(FileFormatI format) { - return Cache.getDefault(format.getName().toUpperCase() + "_JVSUFFIX", + return Cache.getDefault(format.getName().toUpperCase(Locale.ROOT) + "_JVSUFFIX", true); } diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index b312474..003b892 100755 --- a/src/jalview/io/IdentifyFile.java +++ b/src/jalview/io/IdentifyFile.java @@ -22,6 +22,7 @@ package jalview.io; import java.io.File; import java.io.IOException; +import java.util.Locale; /** * DOCUMENT ME! @@ -178,7 +179,7 @@ public class IdentifyFile break; } } - data = data.toUpperCase(); + data = data.toUpperCase(Locale.ROOT); if (data.startsWith(ScoreMatrixFile.SCOREMATRIX)) { @@ -319,7 +320,7 @@ public class IdentifyFile if ((lessThan > -1)) // possible Markup Language data i.e HTML, // RNAML, XML { - String upper = data.toUpperCase(); + String upper = data.toUpperCase(Locale.ROOT); if (upper.substring(lessThan).startsWith("