Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libpromises/rlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,12 @@ static int LaunchParsingMachine(const char *str, Rlist **newlist)
{
current_state = ST_ELM2;
}
else if (CLASS_BRA2(*s))
{
/* A trailing comma, as in { "a", }. Two commas in a row
* still fall through to the catch-all below. */
current_state = ST_PRECLOSED;
}
else if (CLASS_ANY6(*s))
{
current_state = ST_ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ body common control
bundle agent test
{
meta:
"description" -> { "CFE-2140", "redmine7578" }
string => "Test that modules are allowed to define lists with trailing commas";

"test_soft_fail"
string => "any",
meta => { "redmine7578" };
string => "windows",
meta => { "ENT-10257" };

commands:
"$(G.cat)"
Expand Down
24 changes: 16 additions & 8 deletions tests/unit/rlist_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,21 @@ static struct ParseRoulette
3, " { ' a\"a ', \" b''b \" , ' c\"c ' } "},
{
3, " { ' a,\"a } { ', \" } b','b \" , ' {, c\"c } ' } "},
/*Single trailing comma */
{
1, "{\"a\",}"},
{
1, "{'a',}"},
{
1, " {\"\",}"},
{
1, " {'',}"},
{
2, " {\"\",\"\",}"},
{
2, " {'','',}"},
{
2, " {'',\"\",}"},
{
-1, (char *)NULL}
};
Expand Down Expand Up @@ -465,12 +480,10 @@ static char *PFR[] = {
"{'\"\"\",\"}",
"{'',\"\",'}",

/* Misplaced commas*/
"{\"a\",}",
/* Misplaced commas. A single trailing comma is allowed, see PR above */
"{,\"a\"}",
"{,,\"a\"}",
"{\"a\",,\"b\"}",
"{'a',}",
"{,'a'}",
"{,,'a'}",
"{'a',,'b'}",
Expand All @@ -480,24 +493,19 @@ static char *PFR[] = {
" {,,}",
" {,,,}",
" {,\"\"}",
" {\"\",}",
" {,\"\",}",
" {\"\",,}",
" {\"\",,,}",
" {,,\"\",,}",
" {\"\",\"\",}",
" {\"\",\"\",,}",
" { \"\" , \"\" , , }",
" {,''}",
" {'',}",
" {,'',}",
" {'',,}",
" {'',,,}",
" {,,'',,}",
" {'','',}",
" {'','',,}",
" { '' , '' , , }",
" {'',\"\",}",
" {\"\",'',,}",
" { '' , \"\" , , }",
" { \"\" , '' , , }",
Expand Down
Loading