Browse files

fix the sflock side of a pdf attachment issue

Presumably correctly reading the contents of the "test.txt" attachment
is a peepdf issue, since the flateDecode() method is called with partial
PDF object headers included instead of just the zlib stream.
  • Loading branch information...
jbremer committed Sep 12, 2018
1 parent b900e11 commit 0d7547f266b73a110109f997d871649de196bdcc
Showing with 13 additions and 4 deletions.
  1. +5 −4 sflock/unpack/
  2. BIN tests/files/bypass_minimized.pdf
  3. +8 −0 tests/
@@ -36,16 +36,17 @@ def unpack(self, password=None, duplicates=None):
if not isinstance(obj.object, peepdf.PDFCore.PDFDictionary):

if "/F" not in obj.object.elements:
el = obj.object.elements
if "/F" not in el and "/UF" not in el:
if "/EF" not in obj.object.elements:
if "/EF" not in el:

filename = obj.object.elements["/F"]
filename = el.get("/F") or el.get("/UF")
if not isinstance(filename, peepdf.PDFCore.PDFString):

ref = obj.object.elements["/EF"]
ref = el["/EF"]
if not isinstance(ref, peepdf.PDFCore.PDFDictionary):

Binary file not shown.
@@ -45,6 +45,14 @@ def test_pdf_is_embedded():
assert len(files[0].children) == 1
assert files[0].children[0].package == "doc"

def test_bypass_minimized():
m = PdfFile(f(b"bypass_minimized.pdf"))
files = list(m.unpack())
assert len(files) == 1
assert files[0].filename == b"test.txt"
# TODO Fix actually reading the contents of this file correctly (which is
# a peepdf issue, AFAICT).

def test_garbage():
m = PdfFile(f(b"garbage.bin"))
assert m.handles() is False

0 comments on commit 0d7547f

Please sign in to comment.