]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use more strict checks for image urls
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 30 Apr 2020 15:53:24 +0000 (16:53 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 30 Apr 2020 15:53:24 +0000 (16:53 +0100)
src/libserver/html.c
src/libserver/html.h

index 23fe72b39d3168a37c5f7be8cca4449cb0c90b5d..33f3dc67621ba63f0b79cb06938e4966c0ec4aa1 100644 (file)
@@ -189,6 +189,11 @@ khash_t(tag_by_name) *html_tag_by_name;
 khash_t(tag_by_id) *html_tag_by_id;
 khash_t(color_by_name) *html_color_by_name;
 
+static struct rspamd_url *rspamd_html_process_url (rspamd_mempool_t *pool,
+                                                                                                  const gchar *start, guint len,
+                                                                                                  struct html_tag_component *comp,
+                                                                                                  bool is_image);
+
 static void
 rspamd_html_library_init (void)
 {
@@ -1356,7 +1361,7 @@ rspamd_html_parse_tag_content (rspamd_mempool_t *pool,
 
 struct rspamd_url *
 rspamd_html_process_url (rspamd_mempool_t *pool, const gchar *start, guint len,
-               struct html_tag_component *comp)
+               struct html_tag_component *comp, bool is_image)
 {
        struct rspamd_url *url;
        guint saved_flags = 0;
@@ -1500,7 +1505,8 @@ rspamd_html_process_url (rspamd_mempool_t *pool, const gchar *start, guint len,
                }
        }
 
-       rc = rspamd_url_parse (url, decoded, dlen, pool, RSPAMD_URL_PARSE_HREF);
+       rc = rspamd_url_parse (url, decoded, dlen, pool,
+                       is_image ? RSPAMD_URL_PARSE_TEXT :RSPAMD_URL_PARSE_HREF);
 
        /* Filter some completely damaged urls */
        if (rc == URI_ERRNO_OK && url->hostlen > 0 &&
@@ -1599,7 +1605,7 @@ rspamd_html_process_url_tag (rspamd_mempool_t *pool, struct html_tag *tag,
                                }
                        }
 
-                       url = rspamd_html_process_url (pool, start, len, comp);
+                       url = rspamd_html_process_url (pool, start, len, comp, false);
 
                        if (url && tag->extra == NULL) {
                                tag->extra = url;
@@ -1764,7 +1770,7 @@ rspamd_html_process_img_tag (rspamd_mempool_t *pool, struct html_tag *tag,
                                        if (img->src) {
 
                                                img->url = rspamd_html_process_url (pool,
-                                                               img->src, fstr.len, NULL);
+                                                               img->src, fstr.len, NULL, true);
 
                                                if (img->url) {
                                                        img->url->flags |= RSPAMD_URL_FLAG_IMAGE;
index 051df5b63019671cc63536d3ab154b1421c62b61..72eac8d79864d7a3ece2da90f2b25846ae9fbd3e 100644 (file)
@@ -172,9 +172,6 @@ gint rspamd_html_tag_by_name (const gchar *name);
  * @param comp
  * @return
  */
-struct rspamd_url *rspamd_html_process_url (rspamd_mempool_t *pool,
-                                                                                       const gchar *start, guint len,
-                                                                                       struct html_tag_component *comp);
 
 #ifdef  __cplusplus
 }