]> source.dussan.org Git - rspamd.git/commitdiff
Do not try to validate empty headers.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 25 Oct 2011 17:20:49 +0000 (21:20 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Tue, 25 Oct 2011 17:20:49 +0000 (21:20 +0400)
Write symbols to log in case of HTTP/Json output.

src/plugins/regexp.c
src/protocol.c

index e4eb823988fb6cab8ba480ee8a176749f50ae754..77c67015c37417016cf2796cc105435b6d5fb389 100644 (file)
@@ -698,7 +698,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar
                                /* Try to match regexp */
                                if (!re->is_raw) {
                                        /* Validate input */
-                                       if (!g_utf8_validate (cur->data, -1, NULL)) {
+                                       if (!cur->data || !g_utf8_validate (cur->data, -1, NULL)) {
                                                cur = g_list_next (cur);
                                                continue;
                                        }
@@ -923,7 +923,7 @@ process_regexp (struct rspamd_regexp *re, struct worker_task *task, const gchar
                                /* Try to match regexp */
                                if (!re->is_raw) {
                                        /* Validate input */
-                                       if (!g_utf8_validate (rh->value, -1, NULL)) {
+                                       if (!rh->value || !g_utf8_validate (rh->value, -1, NULL)) {
                                                cur = g_list_next (cur);
                                                continue;
                                        }
index 8d72420a19cdf2479ebdddb2321438111682673c..73f8b9de617083f7cf6211db7321bf6ada60cb62 100644 (file)
@@ -898,6 +898,8 @@ metric_symbols_callback_json (gpointer key, gpointer value, void *user_data)
        }
        cd->symbols_offset += rspamd_snprintf (cd->symbols_buf + cd->symbols_offset, cd->symbols_size - cd->symbols_offset,
                        "      },");
+       cd->log_offset += rspamd_snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset,
+                               "%s,", (gchar *)key);
 }
 /*
  * Print a single symbol using json protocol
@@ -917,6 +919,10 @@ show_metric_symbols_json (struct metric_result *metric_res, struct metric_callba
        g_hash_table_foreach (h, metric_symbols_callback_json, cd);
        g_hash_table_unref (h);
        if (cd->alive) {
+               /* Remove last , from log buf */
+               if (cd->log_buf[cd->log_offset - 1] == ',') {
+                       cd->log_buf[--cd->log_offset] = '\0';
+               }
                /* Remove last ',' symbol */
                if (cd->symbols_buf[cd->symbols_offset - 1] == ',') {
                        cd->symbols_buf[--cd->symbols_offset] = '\0';