From 637daf9d276fbafbf6aa76c600e3702716ec2215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=B6llendorf?= Date: Tue, 14 May 2024 18:23:08 +0200 Subject: [PATCH] Fix parsing of section names containing whitespaces fixes #162 --- src/iniparser.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/iniparser.c b/src/iniparser.c index 80886e8..4cffb96 100644 --- a/src/iniparser.c +++ b/src/iniparser.c @@ -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 ;