From: Vsevolod Stakhov Date: Tue, 8 Jan 2013 14:33:37 +0000 (+0400) Subject: Fix ',' in /history handler. X-Git-Tag: 0.5.4~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e43f85561bb422b8b8e3de1015876207388549cd;p=thirdparty%2Frspamd.git Fix ',' in /history handler. --- diff --git a/src/webui.c b/src/webui.c index 9b525842ba..8f2c4216bf 100644 --- a/src/webui.c +++ b/src/webui.c @@ -847,6 +847,9 @@ http_handle_history (struct evhttp_request *req, gpointer arg) row = &copied_history.rows[row_num]; /* Get only completed rows */ if (row->completed) { + if (i != 0) { + evbuffer_add (evb, ",", 1); + } tm = localtime (&row->tv.tv_sec); strftime (timebuf, sizeof (timebuf), "%F %H:%M:%S", tm); #ifdef HAVE_INET_PTON @@ -862,14 +865,14 @@ http_handle_history (struct evhttp_request *req, gpointer arg) if (row->user[0] != '\0') { evbuffer_add_printf (evb, "{\"time\":\"%s\",\"id\":\"%s\",\"ip\":\"%s\",\"action\":\"%s\"," "\"score\":%.2f,\"required_score\": %.2f,\"symbols\":\"%s\",\"size\":%zd,\"scan_time\":%u," - "\"user\":\"%s\"}%s", timebuf, row->message_id, ip_buf, str_action_metric (row->action), - row->score, row->required_score, row->symbols, row->len, row->scan_time, row->user, i == HISTORY_MAX_ROWS - 1 ? "" : ","); + "\"user\":\"%s\"}", timebuf, row->message_id, ip_buf, str_action_metric (row->action), + row->score, row->required_score, row->symbols, row->len, row->scan_time, row->user); } else { evbuffer_add_printf (evb, "{\"time\":\"%s\",\"id\":\"%s\",\"ip\":\"%s\",\"action\":\"%s\"," - "\"score\": %.2f,\"required_score\":%.2f,\"symbols\":\"%s\",\"size\":%zd,\"scan_time\":%u}%s", + "\"score\": %.2f,\"required_score\":%.2f,\"symbols\":\"%s\",\"size\":%zd,\"scan_time\":%u}", timebuf, row->message_id, ip_buf, str_action_metric (row->action), - row->score, row->required_score, row->symbols, row->len, row->scan_time, i == HISTORY_MAX_ROWS - 1 ? "" : ","); + row->score, row->required_score, row->symbols, row->len, row->scan_time); } } }