diff libpurple/util.c @ 30617:b8782b02330d

Catch some more invalid email addresses, thanks to Mark for additional tests (not that I agree with all of them)
author Stu Tomlinson <stu@nosnilmot.com>
date Tue, 15 Jun 2010 01:28:17 +0000
parents a414593d0a78
children 81ffeb069847 1f44f0144ff8
line wrap: on
line diff
--- 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);