================== Info_SetValueForKey Changes or adds a key/value pair ================== */
| 881 | ================== |
| 882 | */ |
| 883 | void Info_SetValueForKey( char *s, const char *key, const char *value ) { |
| 884 | char newi[MAX_INFO_STRING]; |
| 885 | const char* blacklist = "\\;\""; |
| 886 | |
| 887 | if ( strlen( s ) >= MAX_INFO_STRING ) { |
| 888 | Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" ); |
| 889 | } |
| 890 | |
| 891 | for(; *blacklist; ++blacklist) |
| 892 | { |
| 893 | if (strchr (key, *blacklist) || strchr (value, *blacklist)) |
| 894 | { |
| 895 | Com_Printf (S_COLOR_YELLOW "Can't use keys or values with a '%c': %s = %s\n", *blacklist, key, value); |
| 896 | return; |
| 897 | } |
| 898 | } |
| 899 | |
| 900 | Info_RemoveKey (s, key); |
| 901 | if (!value || !strlen(value)) |
| 902 | return; |
| 903 | |
| 904 | Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value); |
| 905 | |
| 906 | if (strlen(newi) + strlen(s) >= MAX_INFO_STRING) |
| 907 | { |
| 908 | Com_Printf ("Info string length exceeded\n"); |
| 909 | return; |
| 910 | } |
| 911 | |
| 912 | strcat (newi, s); |
| 913 | strcpy (s, newi); |
| 914 | } |
| 915 | |
| 916 | /* |
| 917 | ================== |
no test coverage detected