pidgin: 04b459a0: Catch some more invalid email addresses,...

nosnilmot at pidgin.im nosnilmot at pidgin.im
Mon Jun 14 21:30:43 EDT 2010


-----------------------------------------------------------------
Revision: 04b459a0054fec05e338c8cb5cdafb9d3feb12b5
Ancestor: df45ef4a7ecbd22816d968415916540e2629c321
Author: nosnilmot at pidgin.im
Date: 2010-06-15T01:28:17
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/04b459a0054fec05e338c8cb5cdafb9d3feb12b5

Modified files:
        libpurple/tests/test_util.c libpurple/util.c

ChangeLog: 

Catch some more invalid email addresses, thanks to Mark for additional
tests (not that I agree with all of them)

-------------- next part --------------
============================================================
--- libpurple/tests/test_util.c	9c02b76b1af268d52783bbb6912d61d036dfb9b2
+++ libpurple/tests/test_util.c	9bde46e7f01384240bb1aa1db759e2f80ed7c5de
@@ -109,13 +109,13 @@ const char *invalid_emails[] = {
 	"colonButNoPort at 127.0.0.1:",
 	""
 	/* "someone-else at 127.0.0.1.26", */
-	/* ".localStartsWithDot at domain.com", */
-	/* "localEndsWithDot. at domain.com", */
-	/* "two..consecutiveDots at domain.com", */
-	/* "domainStartsWithDash at -domain.com", */
+	".localStartsWithDot at domain.com",
+	/* "localEndsWithDot. at domain.com", */ /* I don't think this is invalid -- Stu */
+	/* "two..consecutiveDots at domain.com", */ /* I don't think this is invalid -- Stu */
+	"domainStartsWithDash at -domain.com",
 	"domainEndsWithDash at domain-.com",
 	/* "numbersInTLD at domain.c0m", */
-	/* "missingTLD at domain.", */
+	/* "missingTLD at domain.", */ /* This certainly isn't invalid -- Stu */
 	"! \"#$%(),/;<>[]`|@invalidCharsInLocal.org",
 	"invalidCharsInDomain@! \"#$%(),/;<>_[]`|.org",
 	/* "local at SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org" */
============================================================
--- libpurple/util.c	f4a91454cdbe3b0ae65c2bd1c50680424315e44f
+++ libpurple/util.c	40d477227df1569d24e08d81df631fca3e531c6b
@@ -4271,6 +4271,8 @@ purple_email_is_valid(const char *addres
 
 	g_return_val_if_fail(address != NULL, FALSE);
 
+	if (*address == '.') return FALSE;
+
 	/* first we validate the name portion (name at domain) (rfc822)*/
 	for (c = address;  *c;  c++) {
 		if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) == '\"')) {
@@ -4304,7 +4306,7 @@ purple_email_is_valid(const char *addres
 	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);


More information about the Commits mailing list