From e43f85561bb422b8b8e3de1015876207388549cd Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 8 Jan 2013 18:33:37 +0400 Subject: [PATCH] Fix ',' in /history handler. --- src/webui.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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); } } } -- 2.47.3