Commit 3a495c19 by Vicent Marti

Merge pull request #2558 from libgit2/cmn/signature-empty-email

signature: don't allow empty emails
parents 31e752b6 76e3c43f
...@@ -70,9 +70,9 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema ...@@ -70,9 +70,9 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
if (p->name == NULL || p->email == NULL) if (p->name == NULL || p->email == NULL)
return -1; /* oom */ return -1; /* oom */
if (p->name[0] == '\0') { if (p->name[0] == '\0' || p->email[0] == '\0') {
git_signature_free(p); git_signature_free(p);
return signature_error("Signature cannot have an empty name"); return signature_error("Signature cannot have an empty name or email");
} }
p->when.time = time; p->when.time = time;
......
...@@ -56,8 +56,8 @@ void test_commit_signature__create_empties(void) ...@@ -56,8 +56,8 @@ void test_commit_signature__create_empties(void)
cl_git_fail(try_build_signature("", "emeric.fermas@gmail.com", 1234567890, 60)); cl_git_fail(try_build_signature("", "emeric.fermas@gmail.com", 1234567890, 60));
cl_git_fail(try_build_signature(" ", "emeric.fermas@gmail.com", 1234567890, 60)); cl_git_fail(try_build_signature(" ", "emeric.fermas@gmail.com", 1234567890, 60));
cl_git_pass(try_build_signature("nulltoken", "", 1234567890, 60)); cl_git_fail(try_build_signature("nulltoken", "", 1234567890, 60));
cl_git_pass(try_build_signature("nulltoken", " ", 1234567890, 60)); cl_git_fail(try_build_signature("nulltoken", " ", 1234567890, 60));
} }
void test_commit_signature__create_one_char(void) void test_commit_signature__create_one_char(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment