aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-09-23 13:44:57 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-09-23 13:44:57 +0100
commitffa32bb64d0fc7bb1bc7f5087927fbc7ccf30651 (patch)
tree38aac8587a9644d989b54c964be6e83946252a5e /src/libmime
parent011a2b7a5ded539e384c5851f1b12d131aedc0f1 (diff)
downloadrspamd-ffa32bb64d0fc7bb1bc7f5087927fbc7ccf30651.tar.gz
rspamd-ffa32bb64d0fc7bb1bc7f5087927fbc7ccf30651.zip
[Feature] Add more text attributes
Diffstat (limited to 'src/libmime')
-rw-r--r--src/libmime/message.c10
-rw-r--r--src/libmime/message.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index a22f51912..ce53c15f9 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -202,6 +202,7 @@ rspamd_extract_words (struct rspamd_task *task,
gchar *temp_word;
const guchar *r;
guint i, nlen, total_len = 0, short_len = 0;
+ gdouble avg_len = 0;
#ifdef WITH_SNOWBALL
static GHashTable *stemmers = NULL;
@@ -252,6 +253,8 @@ rspamd_extract_words (struct rspamd_task *task,
#endif
if (w->len > 0 && (w->flags & RSPAMD_STAT_TOKEN_FLAG_TEXT)) {
+ avg_len = avg_len + (w->len - avg_len) / (double)i;
+
if (r != NULL) {
nlen = strlen (r);
nlen = MIN (nlen, w->len);
@@ -462,6 +465,13 @@ rspamd_strip_newlines_parse (const gchar *begin, const gchar *pe,
part->non_ascii_chars ++;
}
else {
+ if (g_ascii_isupper (*p)) {
+ part->capital_letters ++;
+ }
+ else if (g_ascii_isdigit (*p)) {
+ part->numeric_characters ++;
+ }
+
part->ascii_chars ++;
}
}
diff --git a/src/libmime/message.h b/src/libmime/message.h
index 8dc06eb3a..3092f3da5 100644
--- a/src/libmime/message.h
+++ b/src/libmime/message.h
@@ -101,6 +101,8 @@ struct rspamd_mime_text_part {
guint double_spaces;
guint non_spaces;
guint empty_lines;
+ guint capital_letters;
+ guint numeric_characters;
};
enum rspamd_received_type {