# HG changeset patch # User Stu Tomlinson # Date 1276565297 0 # Node ID b8782b02330d235deaba2240a725d8b06b3367a5 # Parent 72d9caae440698d9b7914078645950310a4c12f9 Catch some more invalid email addresses, thanks to Mark for additional tests (not that I agree with all of them) diff -r 72d9caae4406 -r b8782b02330d libpurple/tests/test_util.c --- a/libpurple/tests/test_util.c Mon Jun 14 22:23:33 2010 +0000 +++ b/libpurple/tests/test_util.c Tue Jun 15 01:28:17 2010 +0000 @@ -109,13 +109,13 @@ "colonButNoPort@127.0.0.1:", "" /* "someone-else@127.0.0.1.26", */ - /* ".localStartsWithDot@domain.com", */ - /* "localEndsWithDot.@domain.com", */ - /* "two..consecutiveDots@domain.com", */ - /* "domainStartsWithDash@-domain.com", */ + ".localStartsWithDot@domain.com", + /* "localEndsWithDot.@domain.com", */ /* I don't think this is invalid -- Stu */ + /* "two..consecutiveDots@domain.com", */ /* I don't think this is invalid -- Stu */ + "domainStartsWithDash@-domain.com", "domainEndsWithDash@domain-.com", /* "numbersInTLD@domain.c0m", */ - /* "missingTLD@domain.", */ + /* "missingTLD@domain.", */ /* This certainly isn't invalid -- Stu */ "! \"#$%(),/;<>[]`|@invalidCharsInLocal.org", "invalidCharsInDomain@! \"#$%(),/;<>_[]`|.org", /* "local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org" */ diff -r 72d9caae4406 -r b8782b02330d libpurple/util.c --- a/libpurple/util.c Mon Jun 14 22:23:33 2010 +0000 +++ b/libpurple/util.c Tue Jun 15 01:28:17 2010 +0000 @@ -4271,6 +4271,8 @@ g_return_val_if_fail(address != NULL, FALSE); + if (*address == '.') return FALSE; + /* first we validate the name portion (name@domain) (rfc822)*/ for (c = address; *c; c++) { if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) == '\"')) { @@ -4304,7 +4306,7 @@ do { if (*c == '.' && (c == domain || *(c - 1) == '.' || *(c - 1) == '-')) return FALSE; - if (*c == '-' && *(c - 1) == '.') return FALSE; + if (*c == '-' && (*(c - 1) == '.' || *(c - 1) == '@')) return FALSE; if ((*c < '0' && *c != '-' && *c != '.') || (*c > '9' && *c < 'A') || (*c > 'Z' && *c < 'a') || (*c > 'z')) return FALSE; } while (*++c);