diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-12 16:36:13 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-12 16:36:32 +0000 |
commit | 43b88f6f4449e822ee2c0782de0da1167b86a4ae (patch) | |
tree | 8ee7f08b81a903b1377a1b0279ae8ca717e049fd /utils | |
parent | 5a777ea6d3b07be9571ac131e4dccaceea347e40 (diff) | |
download | rspamd-43b88f6f4449e822ee2c0782de0da1167b86a4ae.tar.gz rspamd-43b88f6f4449e822ee2c0782de0da1167b86a4ae.zip |
[Feature] Add boundaries parsing in content type
Diffstat (limited to 'utils')
-rw-r--r-- | utils/content_type_bench.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/utils/content_type_bench.c b/utils/content_type_bench.c index 556d76030..b6c067c79 100644 --- a/utils/content_type_bench.c +++ b/utils/content_type_bench.c @@ -27,6 +27,7 @@ static gint total_type = 0; static gint total_subtype = 0; static gint total_charset = 0; static gint total_attrs = 0; +static gint total_boundaries = 0; static gboolean verbose = 1; #define MODE_NORMAL 0 @@ -99,6 +100,9 @@ rspamd_process_file (const gchar *fname, gint mode) if (ct->charset.len > 0) { total_charset ++; } + if (ct->boundary.len > 0) { + total_boundaries ++; + } if (ct->attrs) { total_attrs ++; } @@ -117,6 +121,9 @@ rspamd_process_file (const gchar *fname, gint mode) if (g_mime_content_type_get_parameter (gct, "charset")) { total_charset ++; } + if (g_mime_content_type_get_parameter (gct, "boundary")) { + total_boundaries ++; + } if (g_mime_content_type_get_params (gct)) { total_attrs ++; } @@ -167,6 +174,31 @@ rspamd_process_file (const gchar *fname, gint mode) t.begin); } } + else if (g_mime_content_type_get_parameter (gct, "charset")) { + if (verbose) { + rspamd_fprintf (stderr, "charset: '%s'gmime\n", + g_mime_content_type_get_parameter (gct, "charset")); + } + } + if (g_mime_content_type_get_parameter (gct, "boundary") && ct->boundary.len) { + t.begin = g_mime_content_type_get_parameter (gct, "boundary"); + t.len = strlen (t.begin); + + if (rspamd_ftok_casecmp (&ct->boundary, &t) == 0) { + total_boundaries ++; + } + else if (verbose) { + rspamd_fprintf (stderr, "boundary: '%*s'(rspamd) '%s'gmime\n", + (gint)ct->boundary.len, ct->boundary.begin, + t.begin); + } + } + else if (g_mime_content_type_get_parameter (gct, "boundary")) { + if (verbose) { + rspamd_fprintf (stderr, "boundary: '%s'gmime\n", + g_mime_content_type_get_parameter (gct, "boundary")); + } + } } else if (verbose) { rspamd_fprintf (stderr, "cannot parse: %v, %d(rspamd), %d(gmime)\n", @@ -219,21 +251,25 @@ main (int argc, char **argv) "Total known type: %d\n" "Total known subtype: %d\n" "Total known charset: %d\n" - "Total has attrs: %d\n", + "Total has attrs: %d\n" + "Total has boundaries: %d\n", total_parsed, total_time, total_valid, total_type, total_subtype, total_charset, - total_attrs); + total_attrs, + total_boundaries); } else { rspamd_printf ("Parsed %d received headers in %.3f seconds\n" "Total valid (parsed by both): %d\n" "Total same type: %d\n" "Total same subtype: %d\n" - "Total same charset: %d\n", + "Total same charset: %d\n" + "Total same boundaries: %d\n", total_parsed, total_time, total_valid, total_type, - total_subtype, total_charset); + total_subtype, total_charset, + total_boundaries); } g_mime_shutdown (); |