commit bdd5c1e: [Minor] Oops, fix crash

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Jul 16 20:28:08 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-07-16 21:25:10 +0100
URL: https://github.com/rspamd/rspamd/commit/bdd5c1ed32352ad0c8b031990dcd457c53ef9e0b (HEAD -> master)

[Minor] Oops, fix crash

---
 src/libserver/html.c |  2 ++
 src/libserver/html.h |  1 +
 src/lua/lua_html.c   | 10 +++++-----
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/libserver/html.c b/src/libserver/html.c
index a377cd6a7..518de98fa 100644
--- a/src/libserver/html.c
+++ b/src/libserver/html.c
@@ -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!");
diff --git a/src/libserver/html.h b/src/libserver/html.h
index 377eda430..29e4dc29b 100644
--- a/src/libserver/html.h
+++ b/src/libserver/html.h
@@ -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;
diff --git a/src/lua/lua_html.c b/src/lua/lua_html.c
index 1b633b03f..6a21dd98d 100644
--- a/src/lua/lua_html.c
+++ b/src/lua/lua_html.c
@@ -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);
 			}


More information about the Commits mailing list