diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-06-18 11:47:32 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-06-18 11:47:32 +0800 |
commit | 1ec23af080cec423ced22f77d2fccdb87c8feba9 (patch) | |
tree | 76d12061c970a01931ce7276f21a971f542055b2 | |
parent | df5492a36f163bb6dd7649bcde7bfdb237f84bf6 (diff) | |
download | pttbbs-1ec23af080cec423ced22f77d2fccdb87c8feba9.tar pttbbs-1ec23af080cec423ced22f77d2fccdb87c8feba9.tar.gz pttbbs-1ec23af080cec423ced22f77d2fccdb87c8feba9.tar.bz2 pttbbs-1ec23af080cec423ced22f77d2fccdb87c8feba9.tar.lz pttbbs-1ec23af080cec423ced22f77d2fccdb87c8feba9.tar.xz pttbbs-1ec23af080cec423ced22f77d2fccdb87c8feba9.tar.zst pttbbs-1ec23af080cec423ced22f77d2fccdb87c8feba9.zip |
some idiots autoforward to themselves
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2845 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/mail.c | 20 | ||||
-rw-r--r-- | mbbsd/record.c | 22 |
2 files changed, 39 insertions, 3 deletions
diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 5c4cdf3e..aab8e145 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -11,6 +11,8 @@ setforward(void) { char buf[80], ip[50] = "", yn[4]; FILE *fp; + int flIdiotSent2Self = 0; + int oidlen = strlen(cuser.userid); sethomepath(buf, cuser.userid); strcat(buf, "/.forward"); @@ -20,7 +22,18 @@ setforward(void) } getdata_buf(b_lines - 1, 0, "請輸入信箱自動轉寄的email地址:", ip, sizeof(ip), DOECHO); - if (ip[0] && ip[0] != ' ' && strcmp(cuser.userid, ip) != 0) { + + /* anti idiots */ + if (strncasecmp(ip, cuser.userid, oidlen) == 0) + { + int addrlen = strlen(ip); + if( addrlen == oidlen || + (addrlen > oidlen && + strcasecmp(ip + oidlen, str_mail_address) == 0)) + flIdiotSent2Self = 1; + } + + if (ip[0] && ip[0] != ' ' && !flIdiotSent2Self) { getdata(b_lines, 0, "確定開啟自動轉信功\能?(Y/n)", yn, sizeof(yn), LCECHO); if (yn[0] != 'n' && (fp = fopen(buf, "w"))) { @@ -31,7 +44,10 @@ setforward(void) } } unlink(buf); - vmsg("取消自動轉信!"); + if(flIdiotSent2Self) + vmsg("自動轉寄是不會設定給自己的,想取消用空白就可以了。"); + else + vmsg("取消自動轉信!"); return 0; } diff --git a/mbbsd/record.c b/mbbsd/record.c index 7d57e471..00c8f11e 100644 --- a/mbbsd/record.c +++ b/mbbsd/record.c @@ -579,10 +579,30 @@ append_record_forward(char *fpath, fileheader_t * record, int size, const char * for (m = strlen(buf) - 2; buf[m] != '/' && m > 0; m--); strcat(buf, ".forward"); // XXX check buffer size if ((fp = fopen(buf, "r"))) { + + int flIdiotSent2Self = 0; + int oidlen = origid ? strlen(origid) : 0; + address[0] = 0; fscanf(fp, "%s", address); // XXX check buffer size fclose(fp); - if (buf[0] != 0 && buf[0] != ' ' && strcmp(address, origid) != 0) { + /* some idiots just set forwarding to themselves. + * and even after we checked "sameid", some still + * set STUPID_ID.bbs@host <- "自以為聰明" + * damn it, we have a complex rule now. + */ + if(oidlen > 0) { + if (strncasecmp(address, origid, oidlen) == 0) + { + int addrlen = strlen(address); + if( addrlen == oidlen || + (addrlen > oidlen && + strcasecmp(address + oidlen, str_mail_address) == 0)) + flIdiotSent2Self = 1; + } + } + + if (buf[0] && buf[0] != ' ' && !flIdiotSent2Self) { buf[n + 1] = 0; strcat(buf, record->filename); append_record(fpath, record, size); |