aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-04-08 14:11:55 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-04-08 14:11:55 +0100
commit508f85e07f5725778455e5f6c7cab6646c5ce781 (patch)
tree0173957d2714acb4def0710b075379d30016c97e
parent4b448965ed4611ac6c44ab66a602b75c088bdc96 (diff)
downloadrspamd-508f85e07f5725778455e5f6c7cab6646c5ce781.tar.gz
rspamd-508f85e07f5725778455e5f6c7cab6646c5ce781.zip
[Minor] Lua_html: Return empty table if no images are there in html
-rw-r--r--src/lua/lua_html.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lua/lua_html.c b/src/lua/lua_html.c
index 7d7e9b7a3..1b633b03f 100644
--- a/src/lua/lua_html.c
+++ b/src/lua/lua_html.c
@@ -271,7 +271,7 @@ lua_html_push_image (lua_State *L, struct html_image *img)
struct lua_html_tag *ltag;
struct rspamd_url **purl;
- lua_newtable (L);
+ lua_createtable (L, 0, 7);
if (img->src) {
lua_pushstring (L, "src");
@@ -334,21 +334,20 @@ lua_html_get_images (lua_State *L)
guint i;
if (hc != NULL) {
- lua_newtable (L);
+ if (hc->images) {
+ lua_createtable (L, hc->images->len, 0);
- if (hc->images && hc->images->len > 0) {
- for (i = 0; i < hc->images->len; i ++) {
- img = g_ptr_array_index (hc->images, i);
+ PTR_ARRAY_FOREACH (hc->images, i, img) {
lua_html_push_image (L, img);
lua_rawseti (L, -2, i + 1);
}
}
else {
- lua_pushnil (L);
+ lua_newtable (L);
}
}
else {
- lua_pushnil (L);
+ lua_newtable (L);
}
return 1;