]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Try to fix has_fake_html rule
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Jul 2021 09:31:36 +0000 (10:31 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Jul 2021 09:31:36 +0000 (10:31 +0100)
src/libmime/mime_expressions.c
src/libserver/html/html.cxx
src/libserver/html/html.h

index 477b1dc5d3291ae8627e6fa9a1ffefc9acf5c869..06b590f51859bef2f7ab6282b93f4233b78fbd63 100644 (file)
@@ -1609,7 +1609,7 @@ rspamd_has_fake_html (struct rspamd_task * task, GArray * args, void *unused)
        gboolean res = FALSE;
 
        PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, text_parts), i, p) {
-               if (IS_TEXT_PART_HTML (p) && (p->html == NULL)) {
+               if (IS_TEXT_PART_HTML (p) && (rspamd_html_get_tags_count(p->html) < 2)) {
                        res = TRUE;
                }
 
index 332229b506951b4f8acad670e3c9ef40071068d8..beec91fac313c04010911bd6e9a709cd28fd5bbb 100644 (file)
@@ -2097,4 +2097,16 @@ rspamd_html_get_parsed_content(void *html_content, rspamd_ftok_t *dest)
        dest->len = hc->parsed.size();
 
        return true;
+}
+
+gsize
+rspamd_html_get_tags_count(void *html_content)
+{
+       auto *hc = rspamd::html::html_content::from_ptr(html_content);
+
+       if (!hc) {
+               return 0;
+       }
+
+       return hc->all_tags.size();
 }
\ No newline at end of file
index cc8039c22aaf45f80da74257db9c733de47e0601..8b690499e47b305ced496be1dee78ebfc2d44b93 100644 (file)
@@ -121,6 +121,13 @@ struct html_image* rspamd_html_find_embedded_image(void *html_content,
  */
 bool rspamd_html_get_parsed_content(void *html_content, rspamd_ftok_t *dest);
 
+/**
+ * Returns number of tags in the html content
+ * @param html_content
+ * @return
+ */
+gsize rspamd_html_get_tags_count(void *html_content);
+
 
 #ifdef  __cplusplus
 }