:return: Tuple of (author, time, (timezone, timezone_neg_utc))
"""
try:
- sep = value.index(b'> ')
+ sep = value.rindex(b'> ')
except ValueError:
return (value, None, (None, False))
try:
with self.assertRaises(ObjectFormatException):
commit.check()
+ def test_mangled_author_line(self):
+ """Mangled author line should successfully parse"""
+ author_line = (
+ b'Karl MacMillan <kmacmill@redhat.com> <"Karl MacMillan '
+ b'<kmacmill@redhat.com>"> 1197475547 -0500'
+ )
+ expected_identity = (
+ b'Karl MacMillan <kmacmill@redhat.com> <"Karl MacMillan '
+ b'<kmacmill@redhat.com>">'
+ )
+ commit = Commit.from_string(
+ self.make_commit_text(author=author_line)
+ )
+
+ # The commit parses properly
+ self.assertEqual(commit.author, expected_identity)
+
+ # But the check fails because the author identity is bogus
+ with self.assertRaises(ObjectFormatException):
+ commit.check()
+
def test_parse_gpgsig(self):
c = Commit.from_string(b"""tree aaff74984cccd156a469afa7d9ab10e4777beb24
author Jelmer Vernooij <jelmer@samba.org> 1412179807 +0200