diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 7eda676f7..7901cd96f 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -232,8 +232,8 @@ static void test_set_email(CuTest *tc) { CuAssertIntEquals(tc, 0, set_email(&email, "bugs@eressea.de")); CuAssertStrEquals(tc, "bugs@eressea.de", email); 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@")); CuAssertStrEquals(tc, "bugs@eressea.de", email); free(email); test_cleanup(); diff --git a/src/util/goodies.c b/src/util/goodies.c index c478bcf83..0794240d5 100644 --- a/src/util/goodies.c +++ b/src/util/goodies.c @@ -82,12 +82,18 @@ static int spc_email_isvalid(const char *address) if (strchr(rfc822_specials, *c)) return 0; } + if (*c!='@') { + /* no @ symbol */ + return -1; + } + domain = ++c; + if (!*c) { + return -1; + } if (c == address || *(c - 1) == '.') return 0; /* next we validate the domain portion (name@domain) */ - if (!*(domain = ++c)) - return 0; do { if (*c == '.') { if (c == domain || *(c - 1) == '.')