git://git.exim.org
/
exim.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8fdf20f
)
Expansions: fix json extract for de-wrapping nested objects. Bug 2322
author
Jeremy Harris
<jgh146exb@wizmail.org>
Sun, 30 Sep 2018 20:42:40 +0000
(21:42 +0100)
committer
Jeremy Harris
<jgh146exb@wizmail.org>
Sun, 30 Sep 2018 20:42:40 +0000
(21:42 +0100)
src/src/expand.c
patch
|
blob
|
history
diff --git
a/src/src/expand.c
b/src/src/expand.c
index 43f572ecaecc89d7ee9d866120417673a14da03d..4a88b4446c97114e7b0b4bf193c13480b803b916 100644
(file)
--- a/
src/src/expand.c
+++ b/
src/src/expand.c
@@
-3869,6
+3869,8
@@
static uschar *
dewrap(uschar * s, const uschar * wrap)
{
uschar * p = s;
dewrap(uschar * s, const uschar * wrap)
{
uschar * p = s;
+unsigned depth = 0;
+BOOL quotesmode = wrap[0] == wrap[1];
while (isspace(*p)) p++;
while (isspace(*p)) p++;
@@
-3879,11
+3881,15
@@
if (*p == *wrap)
while (*p)
{
if (*p == '\\') p++;
while (*p)
{
if (*p == '\\') p++;
+ else if (!quotesmode && *p == wrap[-1]) depth++;
else if (*p == *wrap)
else if (*p == *wrap)
- {
- *p = '\0';
- return s;
- }
+ if (depth == 0)
+ {
+ *p = '\0';
+ return s;
+ }
+ else
+ depth--;
p++;
}
}
p++;
}
}
@@
-3917,7
+3923,9
@@
for (item = s;
case '}': object_depth--; break;
}
*list = *s ? s+1 : s;
case '}': object_depth--; break;
}
*list = *s ? s+1 : s;
-return string_copyn(item, s - item);
+item = string_copyn(item, s - item);
+DEBUG(D_expand) debug_printf_indent(" json ele: '%s'\n", item);
+return US item;
}
}