Merge pull request #96 from sschuberth/patch-1
TrueTypeFont: Check for enough data to unpackpull/114/head
commit
3e6cc20cb2
|
@ -383,10 +383,16 @@ class TrueTypeFont(object):
|
|||
self.fp = fp
|
||||
self.tables = {}
|
||||
self.fonttype = fp.read(4)
|
||||
try:
|
||||
(ntables, _1, _2, _3) = struct.unpack('>HHHH', fp.read(8))
|
||||
for _ in range(ntables):
|
||||
(name, tsum, offset, length) = struct.unpack('>4sLLL', fp.read(16))
|
||||
self.tables[name] = (offset, length)
|
||||
except struct.error:
|
||||
# Do not fail if there are not enough bytes to read. Even for
|
||||
# corrupted PDFs we would like to get as much information as
|
||||
# possible, so continue.
|
||||
pass
|
||||
return
|
||||
|
||||
def create_unicode_map(self):
|
||||
|
|
Binary file not shown.
|
@ -53,5 +53,9 @@ class TestDumpPDF():
|
|||
|
||||
def test_9(self):
|
||||
run('../samples/nonfree/','175') # https://github.com/pdfminer/pdfminer.six/issues/65
|
||||
|
||||
def test_10(self):
|
||||
run('../samples/scancode/','patchelf') # https://github.com/euske/pdfminer/issues/96
|
||||
|
||||
if __name__ == '__main__':
|
||||
nose.runmodule()
|
||||
|
|
Loading…
Reference in New Issue