Skip to content

Commit

Permalink
Fix parsing of section names containing whitespaces
Browse files Browse the repository at this point in the history
fixes #162
  • Loading branch information
lmoellendorf committed May 14, 2024
1 parent d4f1ea3 commit 637daf9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/iniparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,13 @@ static line_status iniparser_line(
sta = LINE_COMMENT ;
} else if (line[0]=='[' && line[len-1]==']') {
/* Section name without opening square bracket */
sscanf(line, "[%s", section);
sscanf(line, "[%[^\n]", section);
len = strlen(section);
/* Section name without closing square bracket */
section[len] = '\0';
len--;
if(section[len-1] == ']')
{
section[len-1] = '\0';
}
strstrip(section);
strlwc(section, section, len);
sta = LINE_SECTION ;
Expand Down

0 comments on commit 637daf9

Please sign in to comment.