From 929862f322cf7ca4c13f9515d611a21e2680e2ba Mon Sep 17 00:00:00 2001 From: Marc Strapetz Date: Tue, 14 Jun 2011 16:56:48 +0200 Subject: Fix IndexOutOfBoundsException when parsing PersonIdent IndexOutOfBoundsException could occur when parsing PersonIdent for which no name is present, as part of a RevCommit (nameB > 0). --- .../tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java index 02a78a5baf..7dff6d1cea 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java @@ -161,6 +161,21 @@ public class RevCommitParseTest extends RepositoryTestCase { assertEquals("", c.getShortMessage()); } + @Test + public void testParse_incompleteAuthorAndCommitter() throws Exception { + final StringBuilder b = new StringBuilder(); + b.append("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"); + b.append("author 1218123387 +0700\n"); + b.append("committer <> 1218123390 -0500\n"); + + final RevCommit c; + c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); + c.parseCanonical(new RevWalk(db), b.toString().getBytes("UTF-8")); + + assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent()); + assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent()); + } + @Test public void testParse_implicit_UTF8_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); -- cgit v1.2.3