From 24af7f298cc0a3b1c9a1ffb5b495cb9485ee6870 Mon Sep 17 00:00:00 2001 From: ludwig Date: Sat, 30 Dec 2006 12:13:25 +0000 Subject: include offending string in error message for varables that contain blacklisted characters git-svn-id: svn://svn.icculus.org/quake3/trunk@1021 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/qcommon/q_shared.c | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'code') diff --git a/code/qcommon/q_shared.c b/code/qcommon/q_shared.c index 9d94f2a..b30688a 100644 --- a/code/qcommon/q_shared.c +++ b/code/qcommon/q_shared.c @@ -1187,29 +1187,21 @@ Changes or adds a key/value pair */ void Info_SetValueForKey( char *s, const char *key, const char *value ) { char newi[MAX_INFO_STRING]; + const char* blacklist = "\\;\""; if ( strlen( s ) >= MAX_INFO_STRING ) { Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" ); } - if (strchr (key, '\\') || strchr (value, '\\')) + for(; *blacklist; ++blacklist) { - Com_Printf ("Can't use keys or values with a \\\n"); - return; - } - - if (strchr (key, ';') || strchr (value, ';')) - { - Com_Printf ("Can't use keys or values with a semicolon\n"); - return; - } - - if (strchr (key, '\"') || strchr (value, '\"')) - { - Com_Printf ("Can't use keys or values with a \"\n"); - return; + if (strchr (key, *blacklist) || strchr (value, *blacklist)) + { + Com_Printf (S_COLOR_YELLOW "Can't use keys or values with a '%c': %s = %s\n", *blacklist, key, value); + return; + } } - + Info_RemoveKey (s, key); if (!value || !strlen(value)) return; @@ -1235,27 +1227,19 @@ Changes or adds a key/value pair */ void Info_SetValueForKey_Big( char *s, const char *key, const char *value ) { char newi[BIG_INFO_STRING]; + const char* blacklist = "\\;\""; if ( strlen( s ) >= BIG_INFO_STRING ) { Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" ); } - if (strchr (key, '\\') || strchr (value, '\\')) + for(; *blacklist; ++blacklist) { - Com_Printf ("Can't use keys or values with a \\\n"); - return; - } - - if (strchr (key, ';') || strchr (value, ';')) - { - Com_Printf ("Can't use keys or values with a semicolon\n"); - return; - } - - if (strchr (key, '\"') || strchr (value, '\"')) - { - Com_Printf ("Can't use keys or values with a \"\n"); - return; + if (strchr (key, *blacklist) || strchr (value, *blacklist)) + { + Com_Printf (S_COLOR_YELLOW "Can't use keys or values with a '%c': %s = %s\n", *blacklist, key, value); + return; + } } Info_RemoveKey_Big (s, key); -- cgit v1.2.3