Mercurial > pidgin.yaz
comparison 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 |
comparison
equal
deleted
inserted
replaced
30615:72d9caae4406 | 30617:b8782b02330d |
---|---|
4269 const char *c, *domain; | 4269 const char *c, *domain; |
4270 static char *rfc822_specials = "()<>@,;:\\\"[]"; | 4270 static char *rfc822_specials = "()<>@,;:\\\"[]"; |
4271 | 4271 |
4272 g_return_val_if_fail(address != NULL, FALSE); | 4272 g_return_val_if_fail(address != NULL, FALSE); |
4273 | 4273 |
4274 if (*address == '.') return FALSE; | |
4275 | |
4274 /* first we validate the name portion (name@domain) (rfc822)*/ | 4276 /* first we validate the name portion (name@domain) (rfc822)*/ |
4275 for (c = address; *c; c++) { | 4277 for (c = address; *c; c++) { |
4276 if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) == '\"')) { | 4278 if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) == '\"')) { |
4277 while (*++c) { | 4279 while (*++c) { |
4278 if (*c == '\\') { | 4280 if (*c == '\\') { |
4302 /* next we validate the domain portion (name@domain) (rfc1035 & rfc1011) */ | 4304 /* next we validate the domain portion (name@domain) (rfc1035 & rfc1011) */ |
4303 if (!*(domain = ++c)) return FALSE; | 4305 if (!*(domain = ++c)) return FALSE; |
4304 do { | 4306 do { |
4305 if (*c == '.' && (c == domain || *(c - 1) == '.' || *(c - 1) == '-')) | 4307 if (*c == '.' && (c == domain || *(c - 1) == '.' || *(c - 1) == '-')) |
4306 return FALSE; | 4308 return FALSE; |
4307 if (*c == '-' && *(c - 1) == '.') return FALSE; | 4309 if (*c == '-' && (*(c - 1) == '.' || *(c - 1) == '@')) return FALSE; |
4308 if ((*c < '0' && *c != '-' && *c != '.') || (*c > '9' && *c < 'A') || | 4310 if ((*c < '0' && *c != '-' && *c != '.') || (*c > '9' && *c < 'A') || |
4309 (*c > 'Z' && *c < 'a') || (*c > 'z')) return FALSE; | 4311 (*c > 'Z' && *c < 'a') || (*c > 'z')) return FALSE; |
4310 } while (*++c); | 4312 } while (*++c); |
4311 | 4313 |
4312 if (*(c - 1) == '-') return FALSE; | 4314 if (*(c - 1) == '-') return FALSE; |