commit d4f4efd: [Fix] Pdf: Support some weird objects with no newline before endobj

Vsevolod Stakhov vsevolod at highsecure.ru
Sun May 10 18:35:08 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-05-10 19:33:37 +0100
URL: https://github.com/rspamd/rspamd/commit/d4f4efdef40b07b452ef12b33cf192be51e0ef4f (HEAD -> master)

[Fix] Pdf: Support some weird objects with no newline before endobj

---
 lualib/lua_content/pdf.lua | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lualib/lua_content/pdf.lua b/lualib/lua_content/pdf.lua
index 92b170534..0e3f024ae 100644
--- a/lualib/lua_content/pdf.lua
+++ b/lualib/lua_content/pdf.lua
@@ -459,6 +459,8 @@ local function parse_object_grammar(obj, task, pdf)
               obj.major, obj.minor, obj_or_err)
           pdf.ref[obj_ref(obj.major, obj.minor)] = obj
         else
+          lua_util.debugm(N, task, 'direct object %s:%s is parsed to raw data: %s',
+              obj.major, obj.minor, obj_or_err)
           pdf.ref[obj_ref(obj.major, obj.minor)] = obj_or_err
           obj.dict = {}
           obj.uncompressed = obj_or_err
@@ -841,8 +843,8 @@ local function extract_outer_objects(task, input, pdf)
     local last = pdf.end_objects[end_pos]
 
     -- 7 is length of `endobj\n`
-    if first + 7 < last then
-      local len = last - first - 7
+    if first + 6 < last then
+      local len = last - first - 6
 
       -- Also get the starting span and try to match it versus obj re to get numbers
       local obj_line_potential = first - 32


More information about the Commits mailing list