From: Nathan Wagner Date: Sun, 9 Dec 2018 16:39:41 +0000 (+0000) Subject: quote json note output X-Git-Tag: v0.4.3~5 X-Git-Url: https://pd.if.org/git/?p=zpackage;a=commitdiff_plain;h=1dd10a8ea007ecf04ddaa5a0ab2fa26c572ecc60 quote json note output --- diff --git a/zpm-note.c b/zpm-note.c index c94e37b..d6c9df1 100644 --- a/zpm-note.c +++ b/zpm-note.c @@ -18,6 +18,9 @@ void show_note(struct zpm_note *n) { if (n->pkgid) { printf("Package: %s\n", n->pkgid); } + if (n->path) { + printf("Path: %s\n", n->pkgid); + } if (n->file) { printf("Hash: %s\n", n->file); } @@ -31,7 +34,12 @@ void jstring(char *field, char *value, int indent, int final) { } printf("\"%s\": ", field); if (value) { - printf("\"%s\": ", value); + while (*value) { + if (strchr("\"\\\b\f\n\r\t", *value)) { + putchar('\\'); + } + putchar(*value++); + } } else { printf("null"); } @@ -51,6 +59,7 @@ void show_json(struct zpm_note *n) { printf("{\n\t\"id\": %" PRId64 ",\n", n->id); jstring("package", n->pkgid, 1, 0); jstring("hash", n->file, 1, 0); + jstring("path", n->path, 1, 0); if (len) { printf("\t\"subject\": \"%.*s\",\n", (int)len, n->note);