From: Alan T. DeKok Date: Thu, 5 Jul 2018 13:22:12 +0000 (-0400) Subject: support nested optional strings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=edb73e367f987478697fdb87fa5b7c696c98506e;p=thirdparty%2Ffreeradius-server.git support nested optional strings --- diff --git a/src/main/command.c b/src/main/command.c index 95c31479626..dd90db80904 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -324,6 +324,7 @@ static int split(char **input, char **output, bool syntax_string) } else if (syntax_string && ((*str == '[') || (*str == '('))) { char end; quote = *(str++); + int count = 0; if (quote == '[') { end = ']'; @@ -336,16 +337,14 @@ static int split(char **input, char **output, bool syntax_string) * only for parsing syntax strings, which CANNOT * have quotes in them. */ - while (*str != end) { + while ((*str != end) || (count > 0)) { if (!*str) { fr_strerror_printf("String ends before closing brace."); return -1; } - if (*str == quote) { - fr_strerror_printf("Nested braces are not allowed."); - return -1; - } + if (*str == quote) count++; + if (*str == end) count--; str++; }