summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2009-10-03 12:06:30 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:40 +0000
commit706c4fbac3b80c5499d5e09df9087a5af65e84e7 (patch)
tree6687795e39edc85034928e3ba004bde22d9a3799 /src/game
parent659ac13af69234f22f573eec20279b44bad6ba6e (diff)
* Strip nonprinting and console-key characters from player names
* Disallow player names beginning with '[skipnotify]' because they trigger the ignore system (thanks googles) * Disallow player names including comment-beginning strings for breaking various parsers (thanks Roman "kevlarman" Tetelman) * Slightly more elegant handling of stripping black from player names (thanks Napkin and peoro)
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_client.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 1582a606..a285f6cc 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -812,6 +812,7 @@ static void G_ClientCleanName( const char *in, char *out, int outSize )
char *p;
int spaces;
qboolean escaped;
+ qboolean invalid = qfalse;
//save room for trailing null byte
outSize--;
@@ -828,21 +829,27 @@ static void G_ClientCleanName( const char *in, char *out, int outSize )
if( colorlessLen == 0 && *in == ' ' )
continue;
+ // don't allow nonprinting characters or (dead) console keys
+ if( *in < ' ' || *in > '}' || *in == '`' )
+ continue;
+
// check colors
if( Q_IsColorString( in ) )
{
in++;
- // don't allow black in a name, period
- if( ColorIndex( *in ) == 0 )
- continue;
-
// make sure room in dest for both chars
if( len > outSize - 2 )
break;
*out++ = Q_COLOR_ESCAPE;
- *out++ = *in;
+
+ // don't allow black in a name, period
+ if( ColorIndex( *in ) == 0 )
+ *out++ = COLOR_WHITE;
+ else
+ *out++ = *in;
+
len += 2;
continue;
}
@@ -880,8 +887,20 @@ static void G_ClientCleanName( const char *in, char *out, int outSize )
*out = 0;
+ // don't allow names beginning with "[skipnotify]" because it messes up /ignore-related code
+ if( !Q_stricmpn( p, "[skipnotify]", 12 ) )
+ invalid = qtrue;
+
+ // don't allow comment-beginning strings because it messes up various parsers
+ if( strstr( p, "//" ) || strstr( p, "/*" ) )
+ invalid = qtrue;
+
// don't allow empty names
if( *p == 0 || colorlessLen == 0 )
+ invalid = qtrue;
+
+ // if something made the name bad, put them back to UnnamedPlayer
+ if( invalid )
Q_strncpyz( p, "UnnamedPlayer", outSize );
}