msodumper/msodraw.py        |    2 +-
 test/doc/pass/tdf141049.doc |binary
 2 files changed, 1 insertion(+), 1 deletion(-)

New commits:
commit adf707e6680ffc03fbd7cd1948a1b0290825214a
Author:     Hossein <hoss...@libreoffice.org>
AuthorDate: Sat Feb 12 21:21:36 2022 +0100
Commit:     Hossein <hoss...@libreoffice.org>
CommitDate: Sat Feb 12 23:51:36 2022 +0330

    Fix doc-dump.py problem with dumping binary data
    
    I was getting this error when invoking:
    
        ./doc-dump.py test/doc/pass/tdf141049.doc
    
    ...
      File "mso-dumper/msodumper/msodraw.py", line 40, in inflate
        return textwrap.fill(base64.b64encode(zlib.decompress(bytes)), 
width=160)
      File "/usr/lib/python3.8/textwrap.py", line 391, in fill
        return w.fill(text)
      File "/usr/lib/python3.8/textwrap.py", line 363, in fill
        return "\n".join(self.wrap(text))
      File "/usr/lib/python3.8/textwrap.py", line 351, in wrap
        chunks = self._split_chunks(text)
      File "/usr/lib/python3.8/textwrap.py", line 337, in _split_chunks
        text = self._munge_whitespace(text)
      File "/usr/lib/python3.8/textwrap.py", line 156, in _munge_whitespace
        text = text.translate(self.unicode_whitespace_trans)
    TypeError: a bytes-like object is required, not 'dict'
    
    To check:
    
        cd test/doc && ./test.py
    
    Or simply run all the tests:
    
        make check
    
    The test fails without this fix in place.
    
    Change-Id: I1573ed0568ceb46c01847008fad0c49d1142420c

diff --git a/msodumper/msodraw.py b/msodumper/msodraw.py
index 15f6a9c..73b698d 100644
--- a/msodumper/msodraw.py
+++ b/msodumper/msodraw.py
@@ -37,7 +37,7 @@ def hexdump(value):
     return "".join(ret)
 
 def inflate(bytes):
-    return textwrap.fill(base64.b64encode(zlib.decompress(bytes)), width=160)
+    return textwrap.fill(base64.b64encode(zlib.decompress(bytes)).decode(), 
width=160)
 
 class RecordHeader:
 
diff --git a/test/doc/pass/tdf141049.doc b/test/doc/pass/tdf141049.doc
new file mode 100644
index 0000000..a6a6955
Binary files /dev/null and b/test/doc/pass/tdf141049.doc differ

Reply via email to