diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-09-28 14:41:22 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-09-28 14:46:16 +0100 |
commit | f9962fb58f9463a9c8969c74871046dbc4c1668c (patch) | |
tree | 834e91854d6e23dfe34dcfb8d63d91ec30205a6c /lualib/lua_content/pdf.lua | |
parent | 2a04d19ac7c5a2d5fa895a0b5f625c7d0ecc34f2 (diff) | |
download | rspamd-f9962fb58f9463a9c8969c74871046dbc4c1668c.tar.gz rspamd-f9962fb58f9463a9c8969c74871046dbc4c1668c.zip |
[Minor] Fix one corner case
Diffstat (limited to 'lualib/lua_content/pdf.lua')
-rw-r--r-- | lualib/lua_content/pdf.lua | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lualib/lua_content/pdf.lua b/lualib/lua_content/pdf.lua index a8b6e984a..f6d5c0bc0 100644 --- a/lualib/lua_content/pdf.lua +++ b/lualib/lua_content/pdf.lua @@ -428,18 +428,23 @@ local function maybe_extract_object_stream(obj, pdf, task) if dict.Length and type(obj.stream) == 'table' then local len = math.min(obj.stream.len, tonumber(maybe_dereference_object(dict.Length, pdf, task)) or 0) - local real_stream = obj.stream.data:span(1, len) + if len > 0 then + local real_stream = obj.stream.data:span(1, len) - local uncompressed, filter_err = maybe_apply_filter(dict, real_stream, pdf, task) + local uncompressed, filter_err = maybe_apply_filter(dict, real_stream, pdf, task) - if uncompressed then - obj.uncompressed = uncompressed - lua_util.debugm(N, task, 'extracted object %s:%s: (%s -> %s)', - obj.major, obj.minor, len, uncompressed:len()) - return obj.uncompressed + if uncompressed then + obj.uncompressed = uncompressed + lua_util.debugm(N, task, 'extracted object %s:%s: (%s -> %s)', + obj.major, obj.minor, len, uncompressed:len()) + return obj.uncompressed + else + lua_util.debugm(N, task, 'cannot extract object %s:%s; len = %s; filter = %s: %s', + obj.major, obj.minor, len, dict.Filter, filter_err) + end else - lua_util.debugm(N, task, 'cannot extract object %s:%s; len = %s; filter = %s: %s', - obj.major, obj.minor, len, dict.Filter, filter_err) + lua_util.debugm(N, task, 'cannot extract object %s:%s; len = %s', + obj.major, obj.minor, len) end end end |