diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-15 12:32:34 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-15 12:32:34 +0000 |
commit | 12e8ccdae81889a10ac64e22c92203c5a2c32810 (patch) | |
tree | a72d19c44475e7efdf4acc2eeca07805eef0fa78 /src/lua/lua_html.c | |
parent | a8fb3a3f5f2bc1847f583ffc969b82708bfccc98 (diff) | |
download | rspamd-12e8ccdae81889a10ac64e22c92203c5a2c32810.tar.gz rspamd-12e8ccdae81889a10ac64e22c92203c5a2c32810.zip |
[Feature] HTML: Specially treat data urls in HTML
Diffstat (limited to 'src/lua/lua_html.c')
-rw-r--r-- | src/lua/lua_html.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/lua/lua_html.c b/src/lua/lua_html.c index 47b8c7dfd..71578e1a4 100644 --- a/src/lua/lua_html.c +++ b/src/lua/lua_html.c @@ -229,6 +229,7 @@ lua_html_has_property (lua_State *L) * - `unknown_element` * - `duplicate_element` * - `unbalanced` + * - `data_urls` */ if (strcmp (propname, "no_html") == 0) { ret = hc->flags & RSPAMD_HTML_FLAG_BAD_START; @@ -248,6 +249,12 @@ lua_html_has_property (lua_State *L) else if (strcmp (propname, "unbalanced") == 0) { ret = hc->flags & RSPAMD_HTML_FLAG_UNBALANCED; } + else if (strcmp (propname, "unbalanced") == 0) { + ret = hc->flags & RSPAMD_HTML_FLAG_UNBALANCED; + } + else if (strcmp (propname, "data_urls") == 0) { + ret = hc->flags & RSPAMD_HTML_FLAG_HAS_DATA_URLS; + } } lua_pushboolean (L, ret); @@ -266,7 +273,21 @@ lua_html_push_image (lua_State *L, struct html_image *img) if (img->src) { lua_pushstring (L, "src"); - lua_pushstring (L, img->src); + + if (img->flags & RSPAMD_HTML_FLAG_IMAGE_DATA) { + struct rspamd_lua_text *t; + + t = lua_newuserdata (L, sizeof (*t)); + t->start = img->src; + t->len = strlen (img->src); + t->flags = 0; + + rspamd_lua_setclass (L, "rspamd{text}", -1); + } + else { + lua_pushstring (L, img->src); + } + lua_settable (L, -3); } @@ -294,6 +315,8 @@ lua_html_push_image (lua_State *L, struct html_image *img) lua_settable (L, -3); lua_pushstring (L, "embedded"); lua_pushboolean (L, img->flags & RSPAMD_HTML_FLAG_IMAGE_EMBEDDED); + lua_pushstring (L, "data"); + lua_pushboolean (L, img->flags & RSPAMD_HTML_FLAG_IMAGE_DATA); lua_settable (L, -3); } |