]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
json: skip raw attributes
authorMatthew Newton <matthew-git@newtoncomputing.co.uk>
Tue, 12 Oct 2021 19:39:23 +0000 (20:39 +0100)
committerMatthew Newton <matthew-git@newtoncomputing.co.uk>
Tue, 12 Oct 2021 21:11:45 +0000 (22:11 +0100)
They tend to have binary stuff that gets incorrectly encoded and
breaks the json output

src/lib/json/json.c

index 5fc421900805711d66111136c4bc48e97c5e806d..d7f00e88895b969f2dfb34e94538177463671ce3 100644 (file)
@@ -553,6 +553,8 @@ static json_object *json_object_afrom_pair_list(TALLOC_CTX *ctx, fr_pair_list_t
                fr_sbuff_t              attr_name;
                struct json_object      *vp_object, *values, *value, *type_name;
 
+               if (vp->da->flags.is_raw) continue;
+
                /*
                 *      Get attribute name and value.
                 */
@@ -679,6 +681,8 @@ static json_object *json_smplobj_afrom_pair_list(TALLOC_CTX *ctx, fr_pair_list_t
                struct json_object      *values = NULL;
                bool                    add_single = false;
 
+               if (vp->da->flags.is_raw) continue;
+
                /*
                 *      Get attribute name and value.
                 */
@@ -799,6 +803,8 @@ static struct json_object *json_array_afrom_pair_list(TALLOC_CTX *ctx, fr_pair_l
                struct json_object      *attrobj = NULL;
                bool                    already_seen = false;
 
+               if (vp->da->flags.is_raw) continue;
+
                /*
                 *      Get attribute name and value.
                 */
@@ -922,6 +928,8 @@ static struct json_object *json_value_array_afrom_pair_list(TALLOC_CTX *ctx, fr_
             vp = fr_pair_list_next(vps, vp)) {
                struct json_object      *value;
 
+               if (vp->da->flags.is_raw) continue;
+
                if (json_afrom_value_box(ctx, &value, vp, format) < 0) {
                        fr_strerror_const("Failed to convert attribute value to JSON object");
                        json_object_put_assert(obj);
@@ -972,6 +980,8 @@ static struct json_object *json_attr_array_afrom_pair_list(UNUSED TALLOC_CTX *ct
                fr_sbuff_t              attr_name;
                struct json_object      *value;
 
+               if (vp->da->flags.is_raw) continue;
+
                fr_sbuff_init(&attr_name, buf, sizeof(buf));
                if (attr_name_with_prefix(&attr_name, vp->da, format) < 0) {
                        return NULL;