aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-16 14:13:58 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-16 14:13:58 +0000
commita3b28bf39609984ddaf1dfb4def6161b398e12ce (patch)
tree8a7c9cde60c7761f1279134294a18d4f380b895d /src
parent99a740ed5d4bbdeee3ede37d6ca77d148d300c13 (diff)
downloadrspamd-a3b28bf39609984ddaf1dfb4def6161b398e12ce.tar.gz
rspamd-a3b28bf39609984ddaf1dfb4def6161b398e12ce.zip
[Rework|Minor] Continue new parser integration
Diffstat (limited to 'src')
-rw-r--r--src/libmime/message.h5
-rw-r--r--src/lua/lua_mimepart.c43
2 files changed, 21 insertions, 27 deletions
diff --git a/src/libmime/message.h b/src/libmime/message.h
index cd5911927..66981ca9e 100644
--- a/src/libmime/message.h
+++ b/src/libmime/message.h
@@ -12,11 +12,12 @@
#include "cryptobox.h"
#include "mime_headers.h"
#include "content_type.h"
-#include <gmime/gmime.h>
struct rspamd_task;
struct controller_session;
struct html_content;
+struct rspamd_image;
+struct rspamd_archive;
enum rspamd_mime_part_flags {
RSPAMD_MIME_PART_TEXT = (1 << 0),
@@ -49,6 +50,8 @@ struct rspamd_mime_part {
union {
struct rspamd_mime_multipart *mp;
struct rspamd_mime_text_part *txt;
+ struct rspamd_image *img;
+ struct rspamd_archive *arch;
} specific;
enum rspamd_mime_part_flags flags;
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index e8c7bd9c8..dba66b818 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -375,8 +375,8 @@ lua_textpart_get_raw_content (lua_State * L)
t = lua_newuserdata (L, sizeof (*t));
rspamd_lua_setclass (L, "rspamd{text}", -1);
- t->start = part->orig->data;
- t->len = part->orig->len;
+ t->start = part->raw.begin;
+ t->len = part->raw.len;
t->flags = 0;
return 1;
@@ -432,12 +432,7 @@ lua_textpart_get_raw_length (lua_State * L)
return 1;
}
- if (part->orig == NULL) {
- lua_pushnumber (L, 0);
- }
- else {
- lua_pushnumber (L, part->orig->len);
- }
+ lua_pushnumber (L, part->raw.len);
return 1;
}
@@ -607,8 +602,8 @@ lua_mimepart_get_content (lua_State * L)
t = lua_newuserdata (L, sizeof (*t));
rspamd_lua_setclass (L, "rspamd{text}", -1);
- t->start = part->content->data;
- t->len = part->content->len;
+ t->start = part->parsed_data.begin;
+ t->len = part->parsed_data.len;
t->flags = 0;
return 1;
@@ -624,7 +619,7 @@ lua_mimepart_get_length (lua_State * L)
return 1;
}
- lua_pushinteger (L, part->content->len);
+ lua_pushinteger (L, part->parsed_data.len);
return 1;
}
@@ -639,13 +634,9 @@ lua_mimepart_get_type (lua_State * L)
lua_pushnil (L);
return 2;
}
-#ifndef GMIME24
- lua_pushstring (L, part->type->type);
- lua_pushstring (L, part->type->subtype);
-#else
- lua_pushstring (L, g_mime_content_type_get_media_type (part->type));
- lua_pushstring (L, g_mime_content_type_get_media_subtype (part->type));
-#endif
+
+ lua_pushlstring (L, part->ct->type.begin, part->ct->type.len);
+ lua_pushlstring (L, part->ct->subtype.begin, part->ct->subtype.len);
return 2;
}
@@ -655,12 +646,12 @@ lua_mimepart_get_filename (lua_State * L)
{
struct rspamd_mime_part *part = lua_check_mimepart (L);
- if (part == NULL || part->filename == NULL) {
+ if (part == NULL || part->cd == NULL || part->cd->filename.len == 0) {
lua_pushnil (L);
return 1;
}
- lua_pushstring (L, part->filename);
+ lua_pushlstring (L, part->cd->filename.begin, part->cd->filename.len);
return 1;
}
@@ -757,12 +748,12 @@ lua_mimepart_get_image (lua_State * L)
return luaL_error (L, "invalid arguments");
}
- if (!(part->flags & RSPAMD_MIME_PART_IMAGE)) {
+ if (!(part->flags & RSPAMD_MIME_PART_IMAGE) || part->specific.img == NULL) {
lua_pushnil (L);
}
else {
pimg = lua_newuserdata (L, sizeof (*pimg));
- *pimg = part->specific_data;
+ *pimg = part->specific.img;
rspamd_lua_setclass (L, "rspamd{image}", -1);
}
@@ -779,12 +770,12 @@ lua_mimepart_get_archive (lua_State * L)
return luaL_error (L, "invalid arguments");
}
- if (!(part->flags & RSPAMD_MIME_PART_ARCHIVE)) {
+ if (!(part->flags & RSPAMD_MIME_PART_ARCHIVE) || part->specific.arch == NULL) {
lua_pushnil (L);
}
else {
parch = lua_newuserdata (L, sizeof (*parch));
- *parch = part->specific_data;
+ *parch = part->specific.arch;
rspamd_lua_setclass (L, "rspamd{archive}", -1);
}
@@ -801,12 +792,12 @@ lua_mimepart_get_text (lua_State * L)
return luaL_error (L, "invalid arguments");
}
- if (!(part->flags & RSPAMD_MIME_PART_TEXT)) {
+ if (!(part->flags & RSPAMD_MIME_PART_TEXT) || part->specific.txt == NULL) {
lua_pushnil (L);
}
else {
ppart = lua_newuserdata (L, sizeof (*ppart));
- *ppart = part->specific_data;
+ *ppart = part->specific.txt;
rspamd_lua_setclass (L, "rspamd{textpart}", -1);
}