diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2017-01-28 15:06:15 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2017-01-28 15:06:15 +0100 |
commit | a4feeb01945e039b39a246f96a1a91b0e4836f01 (patch) | |
tree | 087e1b48290ed529412e8ad48efa341952ee2f1b /org.eclipse.jgit.pgm/src/org | |
parent | 2eb1bebd605852b7ef240e700943dfba7c0a1b3f (diff) | |
download | jgit-a4feeb01945e039b39a246f96a1a91b0e4836f01.tar.gz jgit-a4feeb01945e039b39a246f96a1a91b0e4836f01.zip |
Don't rely on default locale when using toUpperCase() and toLowerCase()
Otherwise these methods may produce unexpected results if used for
strings that are intended to be interpreted locale independently.
Examples are programming language identifiers, protocol keys, and HTML
tags. For instance, "TITLE".toLowerCase() in a Turkish locale returns
"t\u0131tle", where '\u0131' is the LATIN SMALL LETTER DOTLESS I
character.
See
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#toLowerCase--
http://blog.thetaphi.de/2012/07/default-locales-default-charsets-and.html
Bug: 511238
Change-Id: Id8d8f37d84d62239c918b81f8d883ed798d87656
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java | 5 | ||||
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java index 62e77285b9..82c401ff86 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java @@ -53,6 +53,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -102,8 +103,8 @@ class Log extends RevWalkTextBuiltin { @Option(name = "--date", usage = "usage_date") void dateFormat(String date) { - if (date.toLowerCase().equals(date)) - date = date.toUpperCase(); + if (date.toLowerCase(Locale.ROOT).equals(date)) + date = date.toUpperCase(Locale.ROOT); dateFormatter = new GitDateFormatter(Format.valueOf(date)); } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java index a0f4d06d40..7d111ffccb 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Main.java @@ -53,6 +53,7 @@ import java.net.URL; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import org.eclipse.jgit.awtui.AwtAuthenticator; import org.eclipse.jgit.awtui.AwtCredentialsProvider; @@ -240,7 +241,8 @@ public class Main { } if (version) { - String cmdId = Version.class.getSimpleName().toLowerCase(); + String cmdId = Version.class.getSimpleName() + .toLowerCase(Locale.ROOT); subcommand = CommandCatalog.get(cmdId).create(); } |