diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-10-16 17:04:53 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-10-16 17:04:53 +0800 |
commit | 308ad7194aa1632322c33d695198fefd7d4f3b79 (patch) | |
tree | a523ad1f22d35e4a7557609281fc39353cd0b8e5 /mbbsd | |
parent | 6c39455827991ffd8a4f6916e776c862cc2aefdf (diff) | |
download | pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar.gz pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar.bz2 pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar.lz pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar.xz pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.tar.zst pttbbs-308ad7194aa1632322c33d695198fefd7d4f3b79.zip |
strip none-big5 char in user's nick
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2257 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/io.c | 33 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 2 |
2 files changed, 26 insertions, 9 deletions
@@ -485,16 +485,33 @@ strip_ansi(char *buf, char *str, int mode) } void -strip_iac(unsigned char *str, int maxlen) +strip_nonebig5(unsigned char *str, int maxlen) { - int i,len=0; - - for(i=0;i<maxlen && str[i]; i++) - if(str[i]!=255) { - str[len++]=str[i]; + int i; + int len=0; + for(i=0;i<maxlen && str[i];i++) { + if(32<=str[i] && str[i]<128) + str[len++]=str[i]; + else if(str[i]==255) { + if(i+1<maxlen) + if(251<=str[i+1] && str[i+1]<=254) { + i++; + if(i+1<maxlen && str[i+1]) + i++; } - if(len<maxlen) - str[len]='\0'; + continue; + } else if(str[i]&0x80) { + if(i+1<maxlen) + if((0x40<=str[i+1] && str[i+1]<=0x7e) || + (0xa1<=str[i+1] && str[i+1]<=0xfe)) { + str[len++]=str[i]; + str[len++]=str[i+1]; + i++; + } + } + } + if(len<maxlen) + str[len]='\0'; } int diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 101299c9..2a0e8167 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -734,7 +734,7 @@ setup_utmp(int mode) strlcpy(uinfo.userid, cuser.userid, sizeof(uinfo.userid)); //strlcpy(uinfo.realname, cuser.realname, sizeof(uinfo.realname)); strlcpy(uinfo.username, cuser.username, sizeof(uinfo.username)); - strip_iac(uinfo.username, sizeof(uinfo.username)); + strip_nonebig5(uinfo.username, sizeof(uinfo.username)); strlcpy(uinfo.from, fromhost, sizeof(uinfo.from)); uinfo.five_win = cuser.five_win; uinfo.five_lose = cuser.five_lose; |