Skip to content

Commit

Permalink
add failing tests for dumppdf crash
Browse files Browse the repository at this point in the history
  • Loading branch information
0xabu committed Sep 6, 2021
1 parent 6b509c5 commit 13dc0ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion tests/test_tools_dumppdf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import warnings

from nose.tools import raises
from helpers import absolute_sample_path
from tempfilepath import TemporaryFilePath
from pdfminer.pdfdocument import PDFNoValidXRefWarning
Expand Down Expand Up @@ -51,3 +51,13 @@ def test_5(self):

def test_6(self):
run('nonfree/naacl06-shinyama.pdf', '-t -a')

@raises(TypeError)
def test_simple1_raw(self):
"""Known issue: crash in dumpxml writing binary to text stream."""
run('simple1.pdf', '-r -a')

@raises(TypeError)
def test_simple1_binary(self):
"""Known issue: crash in dumpxml writing binary to text stream."""
run('simple1.pdf', '-b -a')
4 changes: 2 additions & 2 deletions tools/dumppdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ def dumpxml(out: TextIO, obj: object, codec: Optional[str] = None) -> None:

if isinstance(obj, PDFStream):
if codec == 'raw':
# Likely bug: writing bytes to text I/O.
# Bug: writing bytes to text I/O. This will raise TypeError.
out.write(obj.get_rawdata()) # type: ignore [arg-type]
elif codec == 'binary':
# Likely bug: writing bytes to text I/O.
# Bug: writing bytes to text I/O. This will raise TypeError.
out.write(obj.get_data()) # type: ignore [arg-type]
else:
out.write('<stream>\n<props>\n')
Expand Down

0 comments on commit 13dc0ba

Please sign in to comment.