Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2017-01-28 14:10:20 +0000
committerMatthias Sohn2017-01-30 21:53:28 +0000
commitdaca0edba32687fe8a777df0da487da017f601e0 (patch)
tree56bd750dcdf1abfcdc5aab2129e261ab2a094783
parent76acd28a6f4d0f38a8a6f5a8c3c347155917ff26 (diff)
downloadegit-daca0edba32687fe8a777df0da487da017f601e0.tar.gz
egit-daca0edba32687fe8a777df0da487da017f601e0.tar.xz
egit-daca0edba32687fe8a777df0da487da017f601e0.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: I5619ce1bde33d6ce2469506a915af9203bae0314 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java7
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreatePatchOperation.java2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java4
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/search/CommitSearchQueryTest.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ResourcePropertyTester.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java5
6 files changed, 16 insertions, 9 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
index 11a536b2d3..d611d5fa5d 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/ConnectProviderOperationTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
+import java.util.Locale;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -93,10 +94,10 @@ public class ConnectProviderOperationTest extends GitTestCase {
// not windows???
return;
}
- if (!device.toLowerCase().equals(device)) {
- path = path.setDevice(device.toLowerCase());
+ if (!device.toLowerCase(Locale.ROOT).equals(device)) {
+ path = path.setDevice(device.toLowerCase(Locale.ROOT));
} else {
- path = path.setDevice(device.toUpperCase());
+ path = path.setDevice(device.toUpperCase(Locale.ROOT));
}
assertNotEquals(path, new Path(gitDir.toString()));
assertNotEquals(path.toFile().toString(),
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreatePatchOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreatePatchOperation.java
index 691a99a5b9..d71e8322b9 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreatePatchOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/CreatePatchOperation.java
@@ -284,7 +284,7 @@ public class CreatePatchOperation implements IEGitOperation {
int brace = segment.indexOf('}');
if (brace > 0) {
String keyword = segment.substring(0, brace);
- keyword = keyword.toUpperCase().replaceAll(" ", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+ keyword = keyword.toUpperCase(Locale.ROOT).replaceAll(" ", "_"); //$NON-NLS-1$ //$NON-NLS-2$
value = processKeyword(commit, DiffHeaderKeyword.valueOf(keyword));
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java
index e3e41bb7db..283c981b40 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ResetOperation.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.egit.core.op;
+import java.util.Locale;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
@@ -84,7 +86,7 @@ public class ResetOperation implements IEGitOperation {
private void reset(IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor,
NLS.bind(CoreText.ResetOperation_performingReset,
- type.toString().toLowerCase(), refName),
+ type.toString().toLowerCase(Locale.ROOT), refName),
type == ResetType.HARD ? 2 : 1);
IProject[] validProjects = null;
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/search/CommitSearchQueryTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/search/CommitSearchQueryTest.java
index 93b6e183f1..06dbca5242 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/search/CommitSearchQueryTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/search/CommitSearchQueryTest.java
@@ -134,7 +134,7 @@ public class CommitSearchQueryTest extends LocalRepositoryTestCase {
CommitSearchSettings settings = createSettings();
settings.setMatchCommit(true);
settings.setCaseSensitive(true);
- settings.setTextPattern(commit.name().toUpperCase(Locale.US));
+ settings.setTextPattern(commit.name().toUpperCase(Locale.ROOT));
CommitSearchQuery query = new CommitSearchQuery(settings);
IStatus status = query.run(new NullProgressMonitor());
assertNotNull(status);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ResourcePropertyTester.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ResourcePropertyTester.java
index c694b44cf0..c7aa2d417f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ResourcePropertyTester.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ResourcePropertyTester.java
@@ -15,6 +15,7 @@ package org.eclipse.egit.ui.internal;
import java.lang.reflect.Method;
import java.net.URISyntaxException;
import java.util.List;
+import java.util.Locale;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IResource;
@@ -140,7 +141,9 @@ public class ResourcePropertyTester extends PropertyTester {
// of the RepositoryState enum values.
if (property.length() > 3 && property.startsWith("is")) { //$NON-NLS-1$
// e.g. isCherryPickingResolved => CHERRY_PICKING_RESOLVED
- String lookFor = property.substring(2,3) + property.substring(3).replaceAll("([A-Z])","_$1").toUpperCase(); //$NON-NLS-1$//$NON-NLS-2$
+ String lookFor = property.substring(2, 3)
+ + property.substring(3).replaceAll("([A-Z])", "_$1") //$NON-NLS-1$//$NON-NLS-2$
+ .toUpperCase(Locale.ROOT);
if (state.toString().equals(lookFor))
return true;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java
index e027b63505..03de68526f 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingViewContentProvider.java
@@ -27,6 +27,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
@@ -245,8 +246,8 @@ public class StagingViewContentProvider extends WorkbenchContentProvider {
boolean isInFilter(StagingEntry stagingEntry) {
String filterString = getFilterString();
return filterString.length() == 0
- || stagingEntry.getPath().toUpperCase()
- .contains(filterString.toUpperCase());
+ || stagingEntry.getPath().toUpperCase(Locale.ROOT)
+ .contains(filterString.toUpperCase(Locale.ROOT));
}
private String getFilterString() {

Back to the top