From 33b38bf654927b41dbff292552fde5ab8bc5cb7b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 25 Nov 2014 18:35:22 +0000 Subject: [PATCH] Tune extended urls output. --- src/client/rspamc.c | 7 ++++++- src/libserver/protocol.c | 11 +++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/client/rspamc.c b/src/client/rspamc.c index 9c2e1976d..393441925 100644 --- a/src/client/rspamc.c +++ b/src/client/rspamc.c @@ -494,7 +494,12 @@ rspamc_symbols_output (ucl_object_t *obj) ucl_object_tostring (cur)); } else if (g_ascii_strcasecmp (ucl_object_key (cur), "urls") == 0) { - emitted = ucl_object_emit (cur, UCL_EMIT_JSON_COMPACT); + if (!extended_urls) { + emitted = ucl_object_emit (cur, UCL_EMIT_JSON_COMPACT); + } + else { + emitted = ucl_object_emit (cur, UCL_EMIT_JSON); + } rspamd_fprintf (stdout, "Urls: %s\n", emitted); free (emitted); } diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index d735d62fd..0c2937c34 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -504,13 +504,12 @@ urls_protocol_cb (gpointer key, gpointer value, gpointer ud) elt = ucl_object_fromstring (url->string); ucl_object_insert_key (obj, elt, "url", 0, false); - elt = ucl_object_fromlstring (url->host, url->hostlen); - ucl_object_insert_key (obj, elt, "host", 0, false); - - elt = ucl_object_fromlstring (url->data, url->datalen); - ucl_object_insert_key (obj, elt, "data", 0, false); + if (url->hostlen > 0) { + elt = ucl_object_fromlstring (url->host, url->hostlen); + ucl_object_insert_key (obj, elt, "host", 0, false); + } - if (url->surbl) { + if (url->surbllen > 0) { elt = ucl_object_fromlstring (url->surbl, url->surbllen); ucl_object_insert_key (obj, elt, "surbl", 0, false); } -- 2.39.5