diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-05-12 09:28:04 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-05-12 09:28:04 +0800 |
commit | c16ce784ddf395c1b4823e9dd9243b01f2a7ae4a (patch) | |
tree | 9bd5ec758f23bcfffc961dd684c53cc829c9b939 /mbbsd/user.c | |
parent | 5a07030f13bacf160ce9c068f6c3b2b68fa72d25 (diff) | |
download | pttbbs-c16ce784ddf395c1b4823e9dd9243b01f2a7ae4a.tar pttbbs-c16ce784ddf395c1b4823e9dd9243b01f2a7ae4a.tar.gz pttbbs-c16ce784ddf395c1b4823e9dd9243b01f2a7ae4a.tar.bz2 pttbbs-c16ce784ddf395c1b4823e9dd9243b01f2a7ae4a.tar.lz pttbbs-c16ce784ddf395c1b4823e9dd9243b01f2a7ae4a.tar.xz pttbbs-c16ce784ddf395c1b4823e9dd9243b01f2a7ae4a.tar.zst pttbbs-c16ce784ddf395c1b4823e9dd9243b01f2a7ae4a.zip |
- user: fix email disallow (banemail) algorithm
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4299 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/user.c')
-rw-r--r-- | mbbsd/user.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/mbbsd/user.c b/mbbsd/user.c index a8fba125..4640c60d 100644 --- a/mbbsd/user.c +++ b/mbbsd/user.c @@ -1329,6 +1329,8 @@ isvalidemail(const char *email) { FILE *fp; char buf[128], *c; + int allow = 0; + if (!strstr(email, "@")) return 0; for (c = strstr(email, "@"); *c != 0; ++c) @@ -1336,9 +1338,9 @@ isvalidemail(const char *email) *c += 32; // allow list + allow = 0; if ((fp = fopen("etc/whitemail", "rt"))) { - int allow = 0; while (fgets(buf, sizeof(buf), fp)) { if (buf[0] == '#') continue; @@ -1382,17 +1384,24 @@ isvalidemail(const char *email) } // reject list + allow = 1; if ((fp = fopen("etc/banemail", "r"))) { - while (fgets(buf, sizeof(buf), fp)) { + while (allow && fgets(buf, sizeof(buf), fp)) { if (buf[0] == '#') continue; chomp(buf); c = buf+1; switch(buf[0]) { - case 'A': if (strcasecmp(c, email) == 0) return 0; - case 'P': if (strcasestr(email, c)) return 0; - case 'S': if (strcasecmp(strstr(email, "@") + 1, c) == 0) return 0; + case 'A': if (strcasecmp(c, email) == 0) + allow = 0; + break; + case 'P': if (strcasestr(email, c)) + allow = 0; + break; + case 'S': if (strcasecmp(strstr(email, "@") + 1, c) == 0) + allow = 0; + break; case 'D': if (strlen(email) > strlen(c)) { // c2 points to starting of possible c. @@ -1401,14 +1410,14 @@ isvalidemail(const char *email) break; c2--; if (*c2 == '.' || *c2 == '@') - return 0; + allow = 0; } break; } } fclose(fp); } - return 1; + return allow; } /* 列出所有註冊使用者 */ |