text_part->html,
text_part->utf_raw_content,
&text_part->exceptions,
- MESSAGE_FIELD (task, urls));
+ MESSAGE_FIELD (task, urls),
+ text_part->mime_part->urls);
if (text_part->utf_content->len == 0) {
text_part->flags |= RSPAMD_MIME_TEXT_PART_FLAG_EMPTY;
part->parsed_data.begin = start;
part->parsed_data.len = len;
part->part_number = MESSAGE_FIELD (task, parts)->len;
+ part->urls = g_ptr_array_new ();
part->raw_headers = rspamd_message_headers_new ();
part->headers_order = NULL;
LUA_REGISTRYINDEX,
p->specific.lua_specific.cbref);
}
+
+ if (p->urls) {
+ g_ptr_array_unref (p->urls);
+ }
}
PTR_ARRAY_FOREACH (msg->text_parts, i, tp) {
}
part->part_number = MESSAGE_FIELD (task, parts)->len;
+ part->urls = g_ptr_array_new ();
g_ptr_array_add (MESSAGE_FIELD (task, parts), part);
msg_debug_mime ("parsed data part %T/%T of length %z (%z orig), %s cte",
&part->ct->type, &part->ct->subtype, part->parsed_data.len,
}
part->part_number = MESSAGE_FIELD (task, parts)->len;
+ part->urls = g_ptr_array_new ();
g_ptr_array_add (MESSAGE_FIELD (task, parts), part);
st->nesting ++;
rspamd_mime_part_get_cte (task, part->raw_headers, part, FALSE);
static struct rspamd_url *
rspamd_html_process_url_tag (rspamd_mempool_t *pool, struct html_tag *tag,
- struct html_content *hc)
+ struct html_content *hc)
{
struct html_tag_component *comp;
GList *cur;
rspamd_mempool_t *pool;
khash_t (rspamd_url_hash) *url_set;
struct rspamd_url *url;
+ GPtrArray *part_urls;
};
static gboolean
cbd->url->querylen, rspamd_url_query_unsafe (cbd->url));
url->flags |= RSPAMD_URL_FLAG_QUERY;
- rspamd_url_set_add_or_increase (cbd->url_set, url);
+
+ if (rspamd_url_set_add_or_increase (cbd->url_set, url) && cbd->part_urls) {
+ g_ptr_array_add (cbd->part_urls, url);
+ }
return TRUE;
}
static void
rspamd_process_html_url (rspamd_mempool_t *pool, struct rspamd_url *url,
- khash_t (rspamd_url_hash) *url_set)
+ khash_t (rspamd_url_hash) *url_set,
+ GPtrArray *part_urls)
{
if (url->flags & RSPAMD_URL_FLAG_UNNORMALISED) {
url->flags |= RSPAMD_URL_FLAG_OBSCURED;
qcbd.pool = pool;
qcbd.url_set = url_set;
qcbd.url = url;
+ qcbd.part_urls = part_urls;
rspamd_url_find_multiple(pool,
rspamd_url_query_unsafe (url), url->querylen,
RSPAMD_URL_FIND_ALL, NULL,
rspamd_html_url_query_callback, &qcbd);
}
+
+ if (part_urls) {
+ g_ptr_array_add (part_urls, url);
+ }
}
static void
static void
rspamd_html_process_img_tag (rspamd_mempool_t *pool, struct html_tag *tag,
- struct html_content *hc, khash_t (rspamd_url_hash) *url_set)
+ struct html_content *hc, khash_t (rspamd_url_hash) *url_set,
+ GPtrArray *part_urls)
{
struct html_tag_component *comp;
struct html_image *img;
if (img->url) {
img->url->flags |= RSPAMD_URL_FLAG_IMAGE;
- rspamd_url_set_add_or_increase (url_set, img->url);
+
+ if (rspamd_url_set_add_or_increase (url_set, img->url) &&
+ part_urls) {
+ g_ptr_array_add (part_urls, img->url);
+ }
}
}
}
struct html_content *hc,
GByteArray *in,
GList **exceptions,
- khash_t (rspamd_url_hash) *url_set)
+ khash_t (rspamd_url_hash) *url_set,
+ GPtrArray *part_urls)
{
const guchar *p, *c, *end, *savep = NULL;
guchar t;
if (url_set != NULL) {
if (rspamd_url_set_add_or_increase (url_set, url)) {
- rspamd_process_html_url (pool, url, url_set);
+ rspamd_process_html_url (pool, url, url_set,
+ part_urls);
}
}
}
if (cur_tag->id == Tag_IMG && !(cur_tag->flags & FL_CLOSING)) {
- rspamd_html_process_img_tag (pool, cur_tag, hc, url_set);
+ rspamd_html_process_img_tag (pool, cur_tag, hc, url_set,
+ part_urls);
}
else if (cur_tag->flags & FL_BLOCK) {
struct html_block *bl;
struct html_content *hc,
GByteArray *in)
{
- return rspamd_html_process_part_full (pool, hc, in, NULL, NULL);
+ return rspamd_html_process_part_full (pool, hc, in, NULL, NULL, NULL);
}
}
url->flags |= RSPAMD_URL_FLAG_QUERY;
- rspamd_url_set_add_or_increase (MESSAGE_FIELD (task, urls), url);
+
+
+ if (rspamd_url_set_add_or_increase (MESSAGE_FIELD (task, urls), url)) {
+ if (cbd->part && cbd->part->mime_part->urls) {
+ g_ptr_array_add (cbd->part->mime_part->urls, url);
+ }
+ }
return TRUE;
}
}
url->flags |= RSPAMD_URL_FLAG_FROM_TEXT;
- rspamd_url_set_add_or_increase (MESSAGE_FIELD (task, urls), url);
+
+ if (rspamd_url_set_add_or_increase (MESSAGE_FIELD (task, urls), url) &&
+ cbd->part->mime_part->urls) {
+ g_ptr_array_add (cbd->part->mime_part->urls, url);
+ }
cbd->part->exceptions = g_list_prepend (
cbd->part->exceptions,