aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-29 15:33:21 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-29 15:33:21 +0100
commit48de4f8df4c808f14030006add82a34b75523b3e (patch)
treed9e278d0901b93454d5d7b9ed8dbeb5bab5491c4
parentd08dd10cf250bb86ee0bfe6e4c5d9414cd98711f (diff)
downloadrspamd-48de4f8df4c808f14030006add82a34b75523b3e.tar.gz
rspamd-48de4f8df4c808f14030006add82a34b75523b3e.zip
Add lines count calculation to text parts.
-rw-r--r--src/libmime/message.c18
-rw-r--r--src/libmime/message.h1
2 files changed, 18 insertions, 1 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index d29aeb2cd..c7b01a7a0 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -1239,7 +1239,8 @@ process_text_part (struct rspamd_task *task,
gboolean is_empty)
{
struct mime_text_part *text_part;
- const gchar *cd;
+ const gchar *cd, *p, *c;
+ guint remain;
/* Skip attachements */
#ifndef GMIME24
@@ -1334,6 +1335,21 @@ process_text_part (struct rspamd_task *task,
text_part->content->len, IS_PART_UTF (text_part), task->cfg->min_word_len,
text_part->urls_offset, TRUE);
rspamd_normalize_text_part (task, text_part);
+
+ /* Calculate number of lines */
+ p = text_part->content->data;
+ remain = text_part->content->len;
+ c = p;
+
+ while (p != NULL && remain > 0) {
+ p = memchr (c, '\n', remain);
+
+ if (p != NULL) {
+ text_part->nlines ++;
+ remain -= p - c + 1;
+ c = p + 1;
+ }
+ }
}
#ifdef GMIME24
diff --git a/src/libmime/message.h b/src/libmime/message.h
index 0f3a0ccb4..c751fc226 100644
--- a/src/libmime/message.h
+++ b/src/libmime/message.h
@@ -47,6 +47,7 @@ struct mime_text_part {
rspamd_fstring_t *diff_str;
GArray *words;
GArray *normalized_words;
+ guint nlines;
};
struct received_header {