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 May 20, 2024
1 parent 991dd60 commit 60f6db1
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 (l && s[0] == s[l - 1] && (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 60f6db1

Please sign in to comment.