}
}
+static inline const gchar *
+rspamd_message_find_body_start (const gchar *headers_end, const gchar *body_end)
+{
+ const gchar *p = headers_end;
+ enum {
+ st_start = 0,
+ st_cr,
+ st_lf,
+ } state = st_start;
+
+ if (headers_end + 1 >= body_end) {
+ return headers_end;
+ }
+
+ switch (state) {
+ case st_start:
+ if (*p == '\r') {
+ p ++;
+ state = st_cr;
+ }
+ else if (*p == '\n') {
+ p ++;
+ state = st_lf;
+ }
+ break;
+ case st_cr:
+ if (*p == '\n' && p < body_end) {
+ /* CRLF */
+ p ++;
+ }
+ break;
+ case st_lf:
+ break;
+ }
+
+ return p;
+}
+
gboolean
rspamd_message_parse (struct rspamd_task *task)
{
hdr_pos = rspamd_string_find_eoh (&str);
if (hdr_pos > 0 && hdr_pos < tmp->len) {
+ static const gchar *body_start;
+
+ body_start = rspamd_message_find_body_start (p + hdr_pos,
+ p + len);
task->raw_headers_content.begin = (gchar *) (p);
- task->raw_headers_content.len = (guint64) (hdr_pos);
+ task->raw_headers_content.len = body_start - p;
if (task->raw_headers_content.len > 0) {
process_raw_headers (task, task->raw_headers,