forked from github/server
BUG 2354: fix email validation.
https://bugs.eressea.de/view.php?id=2354
This commit is contained in:
parent
78f8ec0173
commit
faf0f48a70
|
@ -232,8 +232,8 @@ static void test_set_email(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, 0, set_email(&email, "bugs@eressea.de"));
|
CuAssertIntEquals(tc, 0, set_email(&email, "bugs@eressea.de"));
|
||||||
CuAssertStrEquals(tc, "bugs@eressea.de", email);
|
CuAssertStrEquals(tc, "bugs@eressea.de", email);
|
||||||
CuAssertIntEquals(tc, -1, set_email(&email, "bad@@eressea.de"));
|
CuAssertIntEquals(tc, -1, set_email(&email, "bad@@eressea.de"));
|
||||||
CuAssertStrEquals(tc, "bugs@eressea.de", email);
|
|
||||||
CuAssertIntEquals(tc, -1, set_email(&email, "eressea.de"));
|
CuAssertIntEquals(tc, -1, set_email(&email, "eressea.de"));
|
||||||
|
CuAssertIntEquals(tc, -1, set_email(&email, "eressea@"));
|
||||||
CuAssertStrEquals(tc, "bugs@eressea.de", email);
|
CuAssertStrEquals(tc, "bugs@eressea.de", email);
|
||||||
free(email);
|
free(email);
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
|
|
@ -82,12 +82,18 @@ static int spc_email_isvalid(const char *address)
|
||||||
if (strchr(rfc822_specials, *c))
|
if (strchr(rfc822_specials, *c))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (*c!='@') {
|
||||||
|
/* no @ symbol */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
domain = ++c;
|
||||||
|
if (!*c) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (c == address || *(c - 1) == '.')
|
if (c == address || *(c - 1) == '.')
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* next we validate the domain portion (name@domain) */
|
/* next we validate the domain portion (name@domain) */
|
||||||
if (!*(domain = ++c))
|
|
||||||
return 0;
|
|
||||||
do {
|
do {
|
||||||
if (*c == '.') {
|
if (*c == '.') {
|
||||||
if (c == domain || *(c - 1) == '.')
|
if (c == domain || *(c - 1) == '.')
|
||||||
|
|
Loading…
Reference in New Issue