Skip to content
Snippets Groups Projects
Commit cceb1fbb authored by rswindell's avatar rswindell
Browse files

When parsing boolean key values, if white-space or a semicolon immediately

follow the special boolean keywords "True", "Yes", or "On", treat the value as
a logical true (1). Previously, if the boolean keyword was followed by a
semicolon (no whitespace separation) or any text with whitespace separation,
the value would be treated as a logical false (0). The  example sexpots.ini at
wiki.synchro.net has comments following some "true" values which caused them
to be interpretted as "false". Bug reported via reddit by FozzTexx.
parent 354b6c4b
No related branches found
No related tags found
No related merge requests found
......@@ -1140,7 +1140,25 @@ iniGetNamedStringList(str_list_t list, const char* section)
static BOOL isTrue(const char* value)
{
return(stricmp(value,"TRUE")==0 || stricmp(value,"YES")==0 || stricmp(value,"ON")==0);
char* str;
char* p;
BOOL is_true;
if(!isalpha(*value))
return FALSE;
if((str=strdup(value)) == NULL)
return FALSE;
/* Truncate value at first space, tab or semicolon for purposes of checking for special boolean words. */
/* This allows comments or white-space to immediately follow a special boolean word: "True", "Yes", or "On" */
p=str;
FIND_CHARSET(p, "; \t");
*p=0;
is_true = (stricmp(str,"TRUE")==0 || stricmp(str,"YES")==0 || stricmp(str,"ON")==0);
free(str);
return is_true;
}
static long parseInteger(const char* value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment