Skip to content

Commit 637daf9

Browse files
committed
Fix parsing of section names containing whitespaces
fixes #162
1 parent d4f1ea3 commit 637daf9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/iniparser.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -734,10 +734,13 @@ static line_status iniparser_line(
734734
sta = LINE_COMMENT ;
735735
} else if (line[0]=='[' && line[len-1]==']') {
736736
/* Section name without opening square bracket */
737-
sscanf(line, "[%s", section);
737+
sscanf(line, "[%[^\n]", section);
738+
len = strlen(section);
738739
/* Section name without closing square bracket */
739-
section[len] = '\0';
740-
len--;
740+
if(section[len-1] == ']')
741+
{
742+
section[len-1] = '\0';
743+
}
741744
strstrip(section);
742745
strlwc(section, section, len);
743746
sta = LINE_SECTION ;

0 commit comments

Comments
 (0)