diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-07-25 15:56:43 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-07-25 16:05:06 +0100 |
commit | 5fd7a90fdaa33f52c59bdb0ca84451e5c1e22365 (patch) | |
tree | da29b9e1576aa6c453adf31d76334c3f9c15525c /src/libserver/html/html.cxx | |
parent | c82c2ccc54d5f99d99782d3282e6f2a8671eef2e (diff) | |
download | rspamd-5fd7a90fdaa33f52c59bdb0ca84451e5c1e22365.tar.gz rspamd-5fd7a90fdaa33f52c59bdb0ca84451e5c1e22365.zip |
[Feature] Add order to urls structure
Diffstat (limited to 'src/libserver/html/html.cxx')
-rw-r--r-- | src/libserver/html/html.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index a848a25d3..ed034b928 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -1328,7 +1328,8 @@ html_process_input(struct rspamd_task *task, GList **exceptions, khash_t (rspamd_url_hash) *url_set, GPtrArray *part_urls, - bool allow_css) -> html_content * + bool allow_css, + std::uint16_t *cur_url_order) -> html_content * { const gchar *p, *c, *end, *start; guchar t; @@ -1372,6 +1373,7 @@ html_process_input(struct rspamd_task *task, g_assert (task != NULL); auto *pool = task->task_pool; + auto cur_url_part_order = 0u; auto *hc = new html_content; rspamd_mempool_add_destructor(task->task_pool, html_content::html_content_dtor, hc); @@ -1472,6 +1474,10 @@ html_process_input(struct rspamd_task *task, struct rspamd_url *maybe_existing = rspamd_url_set_add_or_return(url_set, maybe_url.value()); if (maybe_existing == maybe_url.value()) { + if (cur_url_order) { + url->order = *(cur_url_order)++; + } + url->part_order = cur_url_part_order++; html_process_query_url(pool, url, url_set, part_urls); } @@ -2273,10 +2279,11 @@ rspamd_html_process_part_full(struct rspamd_task *task, GByteArray *in, GList **exceptions, khash_t (rspamd_url_hash) *url_set, GPtrArray *part_urls, - bool allow_css) + bool allow_css, + uint16_t *cur_url_order) { return rspamd::html::html_process_input(task, in, exceptions, url_set, - part_urls, allow_css); + part_urls, allow_css, cur_url_order); } void * @@ -2286,9 +2293,10 @@ rspamd_html_process_part(rspamd_mempool_t *pool, struct rspamd_task fake_task; memset(&fake_task, 0, sizeof(fake_task)); fake_task.task_pool = pool; + uint16_t order = 0; return rspamd_html_process_part_full (&fake_task, in, NULL, - NULL, NULL, FALSE); + NULL, NULL, FALSE, &order); } guint |