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 | 593a5909e965d17f23d734488a1915d9f9fb6b33 (patch) | |
tree | b84cbeb05f16643b86a7ad44ef921e11a9c0eba1 | |
parent | d39b2fcf092cc073ca5e385b5c991451c4c486b3 (diff) | |
download | pttbbs-593a5909e965d17f23d734488a1915d9f9fb6b33.tar pttbbs-593a5909e965d17f23d734488a1915d9f9fb6b33.tar.gz pttbbs-593a5909e965d17f23d734488a1915d9f9fb6b33.tar.bz2 pttbbs-593a5909e965d17f23d734488a1915d9f9fb6b33.tar.lz pttbbs-593a5909e965d17f23d734488a1915d9f9fb6b33.tar.xz pttbbs-593a5909e965d17f23d734488a1915d9f9fb6b33.tar.zst pttbbs-593a5909e965d17f23d734488a1915d9f9fb6b33.zip |
- user: fix email disallow (banemail) algorithm
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@4299 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/mbbsd/user.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/pttbbs/mbbsd/user.c b/pttbbs/mbbsd/user.c index a8fba125..4640c60d 100644 --- a/pttbbs/mbbsd/user.c +++ b/pttbbs/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; } /* 列出所有註冊使用者 */ |