diff options
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java | 13 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java index 3f58b7501f..9fc7fca987 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java @@ -1493,8 +1493,8 @@ public class ObjectCheckerTest { } StringBuilder b = new StringBuilder(); - entry(b, "100644 \u00C1"); - entry(b, "100644 \u004a\u0301"); + entry(b, "100644 \u0065\u0301"); + entry(b, "100644 \u00e9"); byte[] data = b.toString().getBytes("UTF-8"); try { checker.setSafeForMacOS(true); @@ -1506,6 +1506,15 @@ public class ObjectCheckerTest { } @Test + public void testInvalidTreeDuplicateNames8() + throws UnsupportedEncodingException, CorruptObjectException { + StringBuilder b = new StringBuilder(); + entry(b, "100644 A"); + checker.setSafeForMacOS(true); + checker.checkTree(b.toString().getBytes("UTF-8")); + } + + @Test public void testRejectNulInPathSegment() { try { checker.checkPathSegment(Constants.encodeASCII("a\u0000b"), 0, 3); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java index 1b135a924c..d8a70c104f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java @@ -382,7 +382,7 @@ public class ObjectChecker { throw new CorruptObjectException("truncated in name"); checkPathSegment2(raw, thisNameB, ptr); if (normalized != null) { - if (normalized.add(normalize(raw, thisNameB, ptr))) + if (!normalized.add(normalize(raw, thisNameB, ptr))) throw new CorruptObjectException("duplicate entry names"); } else if (duplicateName(raw, thisNameB, ptr)) throw new CorruptObjectException("duplicate entry names"); |