mirror of
https://git.proxmox.com/git/libgit2
synced 2025-07-05 17:04:15 +00:00
signature: don't blow up trying to parse names containing '>'
When trying to find the end of an email, instead of starting at the beginning of the signature, we start at the end of the name (after the first '<'). This brings libgit2 more in line with Git's behavior when reading out existing signatures. However, note that Git does not allow names like these through the usual porcelain; instead, it silently strips any '>' characters it sees.
This commit is contained in:
parent
15b0bed2ba
commit
6f2856f308
@ -279,7 +279,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
|
||||
if ((name_end = strchr(buffer, '<')) == NULL)
|
||||
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Cannot find '<' in signature");
|
||||
|
||||
if ((email_end = strchr(buffer, '>')) == NULL)
|
||||
if ((email_end = strchr(name_end, '>')) == NULL)
|
||||
return git__throw(GIT_EOBJCORRUPTED, "Failed to parse signature. Cannot find '>' in signature");
|
||||
|
||||
if (email_end < name_end)
|
||||
|
@ -412,6 +412,14 @@ BEGIN_TEST(parse1, "parse the signature line in a commit")
|
||||
1234567890,
|
||||
0);
|
||||
|
||||
TEST_SIGNATURE_PASS(
|
||||
"author A U Thor> <author@example.com> and others 1234567890\n",
|
||||
"author ",
|
||||
"A U Thor>",
|
||||
"author@example.com",
|
||||
1234567890,
|
||||
0);
|
||||
|
||||
TEST_SIGNATURE_FAIL(
|
||||
"committer Vicent Marti tanoku@gmail.com> 123456 -0100 \n",
|
||||
"committer ");
|
||||
|
Loading…
Reference in New Issue
Block a user