Do not treat these as embedded braces
if (*str == '{' && (end = strchr(str, '}')) != NULL) {
/* %{long_key} */
unsigned int ctr = 1;
+ bool escape = FALSE;
end = str;
while(*++end != '\0' && ctr > 0) {
+ if (!escape && *end == '\\') {
+ escape = TRUE;
+ continue;
+ }
+ if (escape) {
+ escape = FALSE;
+ continue;
+ }
if (*end == '{') ctr++;
if (*end == '}') ctr--;
}
/* long key */
*idx_r = ++i;
for (; str[i] != '\0'; i++) {
+ if (!escape && str[i] == '\\') {
+ escape = TRUE;
+ continue;
+ }
+ if (escape) {
+ escape = FALSE;
+ continue;
+ }
if (str[i] == '{')
depth++;
if (str[i] == '}') {