Skip to content

Commit

Permalink
Support quoted INI string values
Browse files Browse the repository at this point in the history
support singly and doubly quoted INI strings, for e.g. leading and trailing spaces in WiFi SSID/PSK field values
  • Loading branch information
nmschulte committed Jul 24, 2023
1 parent 56a40a0 commit 02c3dce
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/inih/ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ static char* lskip(const char* s)
return (char*)s;
}

/* Strip quotes from single and double quoted strings */
static char* unquote(char* s)
{
int l = strlen(s);
if (s[0] == s[l] && (s[0] == '\'' || s[0] == '"'))
{
s[l - 1] = '\0';
s++;
}
return s;
}

/* Return pointer to first char (of chars) or inline comment in given string,
or pointer to null at end of string if neither found. Inline comment must
be prefixed by a whitespace character to register as a comment. */
Expand Down Expand Up @@ -194,6 +206,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
#endif
value = lskip(value);
rstrip(value);
unquote(value);

/* Valid name[=:]value pair found, call handler */
strncpy0(prev_name, name, sizeof(prev_name));
Expand Down

0 comments on commit 02c3dce

Please sign in to comment.