diff options
author | Shawn Pearce <sop@google.com> | 2014-11-24 10:27:49 -0800 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2014-12-18 14:48:52 +0100 |
commit | 07612a610f99ce32b8409a854c74d7761e8f38eb (patch) | |
tree | acde752e26210ec8a26d3247ac5f31501d18cf41 | |
parent | 8d36fa343c689d1334ddc1f722c153203c1d13f7 (diff) | |
download | jgit-07612a610f99ce32b8409a854c74d7761e8f38eb.tar.gz jgit-07612a610f99ce32b8409a854c74d7761e8f38eb.zip |
Always ignore case when forbidding .git in ObjectChecker
The component name ".GIT" inside a tree entry could confuse a
case insensitive filesystem into looking at a submodule and
not a directory entry.
Disallow any case permutations of ".git" to prevent this
confusion from entering a repository and showing up at a
later date on a case insensitive system.
Change-Id: Iaa3f768931d0d5764bf07ac5f6f3ff2b1fdda01b
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java | 17 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java | 10 |
2 files changed, 5 insertions, 22 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 9fc7fca987..f3db2f65da 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 @@ -1295,26 +1295,11 @@ public class ObjectCheckerTest { } @Test - public void testInvalidTreeNameIsMixedCaseGitWindows() { + public void testInvalidTreeNameIsMixedCaseGit() { StringBuilder b = new StringBuilder(); entry(b, "100644 .GiT"); byte[] data = Constants.encodeASCII(b.toString()); try { - checker.setSafeForWindows(true); - checker.checkTree(data); - fail("incorrectly accepted an invalid tree"); - } catch (CorruptObjectException e) { - assertEquals("invalid name '.GiT'", e.getMessage()); - } - } - - @Test - public void testInvalidTreeNameIsMixedCaseGitMacOS() { - StringBuilder b = new StringBuilder(); - entry(b, "100644 .GiT"); - byte[] data = Constants.encodeASCII(b.toString()); - try { - checker.setSafeForMacOS(true); checker.checkTree(data); fail("incorrectly accepted an invalid tree"); } catch (CorruptObjectException e) { 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 d8a70c104f..92b4e39d5b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectChecker.java @@ -540,12 +540,10 @@ public class ObjectChecker { return 1 <= c && c <= 31; } - private boolean isDotGit(byte[] buf, int p) { - if (windows || macosx) - return toLower(buf[p]) == 'g' - && toLower(buf[p + 1]) == 'i' - && toLower(buf[p + 2]) == 't'; - return buf[p] == 'g' && buf[p + 1] == 'i' && buf[p + 2] == 't'; + private static boolean isDotGit(byte[] buf, int p) { + return toLower(buf[p]) == 'g' + && toLower(buf[p + 1]) == 'i' + && toLower(buf[p + 2]) == 't'; } private static char toLower(byte b) { |