mirror of
https://github.com/glest/glest-source.git
synced 2025-08-22 16:02:50 +02:00
- bugfix for IRC nicks using non standard ascii chars (we replace invalid chars on IRC with -
This commit is contained in:
@@ -253,6 +253,8 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||||||
string netPlayerName=Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str());
|
string netPlayerName=Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str());
|
||||||
string ircname=netPlayerName.substr(0,9);
|
string ircname=netPlayerName.substr(0,9);
|
||||||
sprintf(szIRCNick,"MG_%s_%d",ircname.c_str(),randomNickId);
|
sprintf(szIRCNick,"MG_%s_%d",ircname.c_str(),randomNickId);
|
||||||
|
normalizeNick(szIRCNick);
|
||||||
|
|
||||||
currentIrcNick=ircname;
|
currentIrcNick=ircname;
|
||||||
consoleIRC.setStringToHighlight(currentIrcNick);
|
consoleIRC.setStringToHighlight(currentIrcNick);
|
||||||
|
|
||||||
|
@@ -36,6 +36,8 @@ enum IRCEventType {
|
|||||||
IRC_evt_exitThread = 1
|
IRC_evt_exitThread = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void normalizeNick(char *nick);
|
||||||
|
|
||||||
class IRCCallbackInterface {
|
class IRCCallbackInterface {
|
||||||
public:
|
public:
|
||||||
virtual void IRC_CallbackEvent(IRCEventType evt, const char* origin, const char **params, unsigned int count) = 0;
|
virtual void IRC_CallbackEvent(IRCEventType evt, const char* origin, const char **params, unsigned int count) = 0;
|
||||||
|
@@ -555,4 +555,51 @@ void IRCThread::execute() {
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void normalizeNick(char *nick) {
|
||||||
|
// http://tools.ietf.org/html/rfc1459#section-2.3.1
|
||||||
|
// <target> ::= <to> [ "," <target> ]
|
||||||
|
// <to> ::= <channel> | <user> '@' <servername> | <nick> | <mask>
|
||||||
|
// <channel> ::= ('#' | '&') <chstring>
|
||||||
|
// <servername> ::= <host>
|
||||||
|
// <host> ::= see RFC 952 [DNS:4] for details on allowed hostnames
|
||||||
|
// <nick> ::= <letter> { <letter> | <number> | <special> }
|
||||||
|
// <mask> ::= ('#' | '$') <chstring>
|
||||||
|
// <chstring> ::= <any 8bit code except SPACE, BELL, NUL, CR, LF and
|
||||||
|
// comma (',')>
|
||||||
|
//
|
||||||
|
// Other parameter syntaxes are:
|
||||||
|
//
|
||||||
|
// <user> ::= <nonwhite> { <nonwhite> }
|
||||||
|
// <letter> ::= 'a' ... 'z' | 'A' ... 'Z'
|
||||||
|
// <number> ::= '0' ... '9'
|
||||||
|
// <special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
|
||||||
|
|
||||||
|
if(nick != NULL && strlen(nick) > 0) {
|
||||||
|
char *newNick = new char[strlen(nick)+1];
|
||||||
|
memset(newNick,0,strlen(nick)+1);
|
||||||
|
bool nickChanged = false;
|
||||||
|
|
||||||
|
for(int i = 0; i < strlen(nick); ++i) {
|
||||||
|
if(nick[i] == '-' || nick[i] == '[' || nick[i] == ']' || nick[i] == '_' ||
|
||||||
|
nick[i] == '\\' || nick[i] == '`' || nick[i] == '^' ||
|
||||||
|
nick[i] == '{' || nick[i] == '}' ||
|
||||||
|
(nick[i] >= '0' && nick[i] <= '9') ||
|
||||||
|
(nick[i] >= 'a' && nick[i] <= 'z') ||
|
||||||
|
(nick[i] >= 'A' && nick[i] <= 'Z')) {
|
||||||
|
strncat(newNick,&nick[i],1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
strcat(newNick,"-");
|
||||||
|
nickChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nickChanged == true) {
|
||||||
|
strcpy(nick,newNick);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete [] newNick;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
Reference in New Issue
Block a user