]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Pdf: Improve logging
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 1 Jun 2020 13:35:26 +0000 (14:35 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 1 Jun 2020 13:35:26 +0000 (14:35 +0100)
lualib/lua_content/pdf.lua

index f98ad232bfcc7e1992bf6fca0b06e1725d9e7950..5d6b45ce06a04949972061b94654a30e9b555b15 100644 (file)
@@ -372,7 +372,7 @@ local function maybe_dereference_object(elt, pdf, task)
       -- No recursion!
       return pdf.ref[ref]
     else
-      lua_util.debugm(N, task, 'cannot dereference %s:%s -> %s',
+      lua_util.debugm(N, task, 'cannot dereference %s:%s -> %s, no object',
           elt[2], elt[3], obj_ref(elt[2], elt[3]))
       return nil
     end
@@ -683,14 +683,16 @@ process_dict = function(task, pdf, obj, dict)
 
     local resources = dict.Resources
     if resources and type(resources) == 'table' then
-      obj.resources = maybe_dereference_object(resources, pdf, task)
+      local res_ref = maybe_dereference_object(resources, pdf, task)
 
-      if type(obj.resources) ~= 'table' then
-        rspamd_logger.infox(task, 'cannot parse resources from pdf: %s returned by grammar',
-            obj.resources)
+      if type(res_ref) ~= 'table' then
+        lua_util.debugm(N, task, 'cannot parse resources from pdf: %s',
+            resources)
+        obj.resources = {}
+      elseif res_ref.dict then
+        obj.resources = res_ref.dict
+      else
         obj.resources = {}
-      elseif obj.resources.dict then
-        obj.resources = obj.resources.dict
       end
     else
       -- Fucking pdf: we need to inherit from parent