diff options
author | default <nobody@localhost> | 2023-04-12 10:41:15 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-04-12 10:41:15 +0200 |
commit | 885031bed9e54876fb262921b11df23aa00cedb6 (patch) | |
tree | a1541acecaa547b5a637600d76e8a0df1fde6225 /data.c | |
parent | aa86357237822b4b988fb24e05c36d12308aa2e0 (diff) |
Don't generate invalid JSON if an attachment has no description.
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -1971,7 +1971,7 @@ void srv_archive(const char *direction, const char *url, xs_dict *req, void srv_archive_error(const char *prefix, const xs_str *err, - const xs_dict *req, const xs_dict *data) + const xs_dict *req, const xs_val *data) /* archives an error */ { xs *ntid = tid(0); @@ -1993,8 +1993,12 @@ void srv_archive_error(const char *prefix, const xs_str *err, if (data) { fprintf(f, "Data:\n"); - xs *j = xs_json_dumps_pp(data, 4); - fwrite(j, strlen(j), 1, f); + if (xs_type(data) == XSTYPE_LIST || xs_type(data) == XSTYPE_DICT) { + xs *j = xs_json_dumps_pp(data, 4); + fwrite(j, strlen(j), 1, f); + } + else + fprintf(f, "%s", data); fprintf(f, "\n"); } |