aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2013-01-08 18:33:37 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2013-01-08 18:33:37 +0400
commite43f85561bb422b8b8e3de1015876207388549cd (patch)
tree636826f18aa21e87fcebd7d9b9bc5dc3c05f8916
parent3ac18652e5190623b1c36dd45a5684ca809acd3c (diff)
downloadrspamd-e43f85561bb422b8b8e3de1015876207388549cd.tar.gz
rspamd-e43f85561bb422b8b8e3de1015876207388549cd.zip
Fix ',' in /history handler.
-rw-r--r--src/webui.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/webui.c b/src/webui.c
index 9b525842b..8f2c4216b 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);
}
}
}