]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix raw_mime regexp on HTML part with no text content
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 4 May 2018 15:03:51 +0000 (16:03 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 4 May 2018 15:03:51 +0000 (16:03 +0100)
Issue: #2218
Closes: #2218
src/libserver/re_cache.c

index 98fe0a39564453c6ae4d537e7ee5640478f5ea6d..c47db5761e38fdcf6faaa45d081b335f9e632300 100644 (file)
@@ -880,26 +880,34 @@ rspamd_re_cache_exec_re (struct rspamd_task *task,
                        for (i = 0; i < task->text_parts->len; i++) {
                                part = g_ptr_array_index (task->text_parts, i);
 
-                               /* Skip empty parts */
-                               if (IS_PART_EMPTY (part)) {
-                                       lenvec[i] = 0;
-                                       scvec[i] = (guchar *) "";
-                                       continue;
-                               }
-
-                               /* Check raw flags */
-                               if (!IS_PART_UTF (part)) {
-                                       raw = TRUE;
-                               }
                                /* Select data for regexp */
                                if (re_class->type == RSPAMD_RE_RAWMIME) {
-                                       in = part->raw.begin;
-                                       len = part->raw.len;
+                                       if (part->raw.len == 0) {
+                                               len = 0;
+                                               in = "";
+                                       }
+                                       else {
+                                               in = part->raw.begin;
+                                               len = part->raw.len;
+                                       }
+
                                        raw = TRUE;
                                }
                                else {
-                                       in = part->content->data;
-                                       len = part->content->len;
+                                       /* Skip empty parts */
+                                       if (IS_PART_EMPTY (part)) {
+                                               len = 0;
+                                               in = "";
+                                       }
+                                       else {
+                                               /* Check raw flags */
+                                               if (!IS_PART_UTF (part)) {
+                                                       raw = TRUE;
+                                               }
+
+                                               in = part->content->data;
+                                               len = part->content->len;
+                                       }
                                }
 
                                scvec[i] = (guchar *) in;