]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Oops, fix crash
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Jul 2020 20:25:10 +0000 (21:25 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Jul 2020 20:25:10 +0000 (21:25 +0100)
src/libserver/html.c
src/libserver/html.h
src/lua/lua_html.c

index a377cd6a72d702481a0b7034eafe393a8e43b08c..518de98fad180a1b552b4e852a4368f2b106ef4d 100644 (file)
@@ -1774,6 +1774,7 @@ rspamd_html_process_img_tag (rspamd_mempool_t *pool, struct html_tag *tag,
        cur = tag->params->head;
        img = rspamd_mempool_alloc0 (pool, sizeof (*img));
        img->tag = tag;
+       tag->flags |= FL_IMAGE;
 
        while (cur) {
                comp = cur->data;
@@ -3180,6 +3181,7 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool,
                                                        msg_debug_html ("got valid base tag");
                                                        hc->base_url = url;
                                                        cur_tag->extra = url;
+                                                       cur_tag->flags |= FL_HREF;
                                                }
                                                else {
                                                        msg_debug_html ("got invalid base tag!");
index 377eda430b147dd0f86f84a6c49a1101d57f4971..29e4dc29b8ebb48ddfd2f95f66b697f8833138fe 100644 (file)
@@ -105,6 +105,7 @@ struct html_block {
 #define FL_IGNORE       (1 << 27)
 #define FL_BLOCK        (1 << 28)
 #define FL_HREF         (1 << 29)
+#define FL_IMAGE        (1 << 30)
 
 struct html_tag {
        gint id;
index 1b633b03fe88632c85b8d98dc2f7d3c262a76efe..6a21dd98d2a2124f4a469392822f0f0b9133a845 100644 (file)
@@ -715,16 +715,16 @@ lua_html_tag_get_extra (lua_State *L)
 
        if (ltag) {
                if (ltag->tag->extra) {
-                       if ((ltag->tag->flags & FL_HREF) || ltag->tag->id == Tag_BASE) {
+                       if (ltag->tag->flags & FL_IMAGE) {
+                               img = ltag->tag->extra;
+                               lua_html_push_image (L, img);
+                       }
+                       else if (ltag->tag->flags & FL_HREF) {
                                /* For A that's URL */
                                purl = lua_newuserdata (L, sizeof (gpointer));
                                *purl = ltag->tag->extra;
                                rspamd_lua_setclass (L, "rspamd{url}", -1);
                        }
-                       else if (ltag->tag->id == Tag_IMG) {
-                               img = ltag->tag->extra;
-                               lua_html_push_image (L, img);
-                       }
                        else if (ltag->tag->flags & FL_BLOCK) {
                                lua_html_push_block (L, ltag->tag->extra);
                        }