Skip to content

Commit

Permalink
Show iniparser_load() copes with quotes, semicolon and hash in attrib…
Browse files Browse the repository at this point in the history
…utes
  • Loading branch information
lmoellendorf committed Apr 20, 2024
1 parent 62bcf53 commit 068b66a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/ressources/quotes.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ string2="str#ing"
string3=str"ing
string4=str;ing
string5=str#ing
str"ing="str\"ing"
"str;ing"="str;ing"
"str#ing"="str#ing"
str:ing="str\"ing"
22 changes: 21 additions & 1 deletion test/test_iniparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,9 @@ void Test_iniparser_quotes(CuTest *tc)
FILE *ini;
int ret;

/**
* Test iniparser_load()
*/
/* check if section has been written as expected */
dic = iniparser_load(QUOTES_INI_PATH);

Expand Down Expand Up @@ -1084,7 +1087,24 @@ void Test_iniparser_quotes(CuTest *tc)
CuAssertStrEquals(tc, "str", iniparser_getstring(dic,
QUOTES_INI_SEC ":" QUOTES_INI_ATTR5, NULL));
/*
* test escaping
* iniparser_load() supports quotes in attributes
*/
CuAssertStrEquals(tc, "str\\", iniparser_getstring(dic,
QUOTES_INI_SEC ":" "str\"ing", NULL));
/*
* iniparser_load() does not support semicolon or hash in attributes
*/
CuAssertStrEquals(tc, NULL, iniparser_getstring(dic,
QUOTES_INI_SEC ":" "str;ing", NULL));
CuAssertStrEquals(tc, NULL, iniparser_getstring(dic,
QUOTES_INI_SEC ":" "str#ing", NULL));
/*
* iniparser_load() does support colon in attributes
*/
CuAssertStrEquals(tc, "str\\", iniparser_getstring(dic,
QUOTES_INI_SEC ":" "str:ing", NULL));
/**
* test iniparser_set()
*/
create_empty_ini_file(TMP_INI_PATH);
dic = iniparser_load(TMP_INI_PATH);
Expand Down

0 comments on commit 068b66a

Please sign in to comment.