aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_html.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-07-23 20:40:41 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-07-23 20:40:41 +0100
commit52833b8ca40da9d81d40e95ff8383fcbc9a10372 (patch)
treee3b5a2f11234e593f55d4f20fc8605b4dcdafbfd /src/lua/lua_html.c
parent48399d64ad71a06072cc1812354616f05b6da348 (diff)
downloadrspamd-52833b8ca40da9d81d40e95ff8383fcbc9a10372.tar.gz
rspamd-52833b8ca40da9d81d40e95ff8383fcbc9a10372.zip
Make R_EMPTY_IMAGE tutorial function.
Diffstat (limited to 'src/lua/lua_html.c')
-rw-r--r--src/lua/lua_html.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/lua/lua_html.c b/src/lua/lua_html.c
index 79abc0a39..855904c38 100644
--- a/src/lua/lua_html.c
+++ b/src/lua/lua_html.c
@@ -33,17 +33,27 @@
* This module provides different methods to access HTML tags. To get HTML context
* from an HTML part you could use method `part:get_html()`
* @example
-rspamd_config.R_HTML_IMAGE = function (task)
- parts = task:get_text_parts()
- if parts then
- for _,part in ipairs(parts) do
- if part:is_html() then
- local html = part:get_html()
- -- Do something with html
- end
- end
- end
- return false
+rspamd_config.R_EMPTY_IMAGE = function(task)
+ local tp = task:get_text_parts() -- get text parts in a message
+
+ for _,p in ipairs(tp) do -- iterate over text parts array using `ipairs`
+ if p:is_html() then -- if the current part is html part
+ local hc = p:get_html() -- we get HTML context
+ local len = p:get_length() -- and part's length
+
+ if len < 50 then -- if we have a part that has less than 50 bytes of text
+ local images = hc:get_images() -- then we check for HTML images
+
+ if images then -- if there are images
+ for _,i in ipairs(images) do -- then iterate over images in the part
+ if i['height'] + i['width'] >= 400 then -- if we have a large image
+ return true -- add symbol
+ end
+ end
+ end
+ end
+ end
+ end
end
*/