1 From b2734f7b45111f9b7de790c7b334a2ece47675b5 Mon Sep 17 00:00:00 2001
2 From: Jeremy Harris <jgh146exb@wizmail.org>
3 Date: Sat, 9 Feb 2019 16:56:59 +0000
4 Subject: [PATCH 1/7] Fix json extract operator for unfound case
6 (cherry picked from commit e73798976812e652320f096870359ef35ed069ff)
8 doc/doc-docbook/spec.xfpt | 4 ++++
9 src/expand.c | 13 ++++++++-----
10 test/scripts/0000-Basic/0002 | 3 +++
11 test/stdout/0002 | 3 +++
12 4 files changed, 18 insertions(+), 5 deletions(-)
16 @@ -3901,7 +3901,8 @@ return NULL;
17 /* Pull off the leading array or object element, returning
18 a copy in an allocated string. Update the list pointer.
20 -The element may itself be an abject or array.
21 +The element may itself be an object or array.
22 +Return NULL when the list is empty.
26 @@ -3923,6 +3924,7 @@ for (item = s;
27 case '}': object_depth--; break;
30 +if (item == s) return NULL;
31 item = string_copyn(item, s - item);
32 DEBUG(D_expand) debug_printf_indent(" json ele: '%s'\n", item);
34 @@ -5790,10 +5792,11 @@ while (*s != 0)
36 while (field_number > 0 && (item = json_nextinlist(&list)))
41 - while (--s >= lookup_value && isspace(*s)) *s = '\0';
42 + if ((lookup_value = s = item))
45 + while (--s >= lookup_value && isspace(*s)) *s = '\0';
52 @@ -8776,6 +8776,8 @@ ${extract json{<key>}{<string1>}{<string
53 The braces, commas and colons, and the quoting of the member name are
54 required; the spaces are optional. Matching of the key against the member
55 names is done case-sensitively.
56 + If a returned value is a JSON string, it retains its leading and
59 The results of matching are handled as above.
61 @@ -8813,6 +8815,8 @@ ${extract json{<number>}}{<string1>}{<st
63 Field selection and result handling is as above; there is no choice of
65 + If a returned value is a JSON string, it retains its leading and
68 ${filter{<string>}{<condition>}}