end
-- This function searches objects for `/URI` key and parses it's content
-local function search_urls(task, pdf)
+local function search_urls(task, pdf, mpart)
local function recursive_object_traverse(obj, dict, rec)
if rec > 10 then
lua_util.debugm(N, task, 'object %s:%s recurses too much',
if url then
lua_util.debugm(N, task, 'found url %s in object %s:%s',
v, obj.major, obj.minor)
- task:inject_url(url)
+ task:inject_url(url, mpart)
end
end
end
end
end
-local function process_pdf(input, _, task)
+local function process_pdf(input, mpart, task)
if not config.enabled then
-- Skip processing
search_text(task, pdf_output)
end
if config.url_extraction then
- search_urls(task, pdf_output)
+ search_urls(task, pdf_output, mpart)
end
if config.js_fuzzy and pdf_output.scripts then
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
struct rspamd_lua_url *url = lua_check_url (L, 2);
+ struct rspamd_mime_part *mpart = NULL;
+
+ if (lua_isuserdata (L, 3)) {
+ /* We also have a mime part there */
+ mpart = *((struct rspamd_mime_part **)rspamd_lua_check_udata_maybe (L,
+ 3, "rspamd{mimepart}"));
+ }
if (task && task->message && url && url->url) {
- rspamd_url_set_add_or_increase (MESSAGE_FIELD (task, urls), url->url);
+ if (rspamd_url_set_add_or_increase (MESSAGE_FIELD (task, urls), url->url)) {
+ if (mpart && mpart->urls) {
+ /* Also add url to the mime part */
+ g_ptr_array_add (mpart->urls, url->url);
+ }
+ }
}
else {
return luaL_error (L, "invalid arguments");