rpmbuild 6aa3dc9
Separate functions for the conversion of the python2 binary string / python3 binarray to ascii/hexdump
rpmbuild 6aa3dc9
This fixes issue with --print-header and --print-directory
rpmbuild 6aa3dc9
--- officeparser-42c2d40372fe271f2039ca1adc145d2aef8c9545/officeparser.py	2019-10-26 19:54:01.632237407 +0200
rpmbuild 6aa3dc9
+++ officeparser-42c2d40372fe271f2039ca1adc145d2aef8c9545.new/officeparser.py	2019-10-26 19:53:55.603999504 +0200
rpmbuild 6aa3dc9
@@ -56,6 +56,23 @@
rpmbuild 6aa3dc9
     maximum_length = (0xFFFF >> bit_count) + 3
rpmbuild 6aa3dc9
     return length_mask, offset_mask, bit_count, maximum_length
rpmbuild 6aa3dc9
 
rpmbuild 6aa3dc9
+
rpmbuild 6aa3dc9
+def to_hex(data):
rpmbuild 6aa3dc9
+    if PY3:
rpmbuild 6aa3dc9
+        hex = ' '.join(['{0:02X}'.format(x) for x in data])
rpmbuild 6aa3dc9
+    else:
rpmbuild 6aa3dc9
+        hex = ' '.join(['{0:02X}'.format(ord(x)) for x in data])
rpmbuild 6aa3dc9
+    return hex
rpmbuild 6aa3dc9
+
rpmbuild 6aa3dc9
+def to_ascii(data):
rpmbuild 6aa3dc9
+    if PY3:
rpmbuild 6aa3dc9
+        # In Python 3 we have numbers we need to convert to chars
rpmbuild 6aa3dc9
+        ascii = ''.join([chr(x) for x in data if x != 0])
rpmbuild 6aa3dc9
+    else:
rpmbuild 6aa3dc9
+        # In Python 2 we have chars we need to convert to numbers to check them
rpmbuild 6aa3dc9
+        ascii = ''.join([x for x in data if ord(x) != 0])
rpmbuild 6aa3dc9
+    return ascii
rpmbuild 6aa3dc9
+
rpmbuild 6aa3dc9
 def decompress_stream(compressed_container):
rpmbuild 6aa3dc9
     # MS-OVBA
rpmbuild 6aa3dc9
     # 2.4.1.2
rpmbuild 6aa3dc9
@@ -342,8 +359,8 @@
rpmbuild 6aa3dc9
 _csectMiniFat       = {15}
rpmbuild 6aa3dc9
 _sectDifStart       = {16}
rpmbuild 6aa3dc9
 _csectDif           = {17}""".format(
rpmbuild 6aa3dc9
-        ' '.join(['{0:02X}'.format(ord(x)) for x in self._abSig]),
rpmbuild 6aa3dc9
-        ' '.join(['{0:02X}'.format(ord(x)) for x in self._clid]),
rpmbuild 6aa3dc9
+        to_hex(self._abSig),
rpmbuild 6aa3dc9
+        to_hex(self._clid),
rpmbuild 6aa3dc9
         '{0:04X}'.format(self._uMinorVersion),
rpmbuild 6aa3dc9
         '{0}'.format(self._uDllVersion),
rpmbuild 6aa3dc9
         '{0:04X}'.format(self._uByteOrder),
rpmbuild 6aa3dc9
@@ -409,12 +426,7 @@
rpmbuild 6aa3dc9
         self._ab = self.directory[0]
rpmbuild 6aa3dc9
         self._cb = self.directory[1]
rpmbuild 6aa3dc9
         # convert wide chars into ASCII
rpmbuild 6aa3dc9
-        if PY3:
rpmbuild 6aa3dc9
-            # In Python 3 we have numbers we need to convert to chars
rpmbuild 6aa3dc9
-            self.name = ''.join([chr(x) for x in self._ab[0:self._cb] if x != 0])
rpmbuild 6aa3dc9
-        else:
rpmbuild 6aa3dc9
-            # In Python 2 we have chars we need to convert to numbers to check them
rpmbuild 6aa3dc9
-            self.name = ''.join([x for x in self._ab[0:self._cb] if ord(x) != 0])
rpmbuild 6aa3dc9
+        self.name = to_ascii(self._ab[0:self._cb])
rpmbuild 6aa3dc9
         self._mse = self.directory[2]
rpmbuild 6aa3dc9
         self._bflags = self.directory[3]
rpmbuild 6aa3dc9
         self._sidLeftSib = self.directory[4]
rpmbuild 6aa3dc9
@@ -444,8 +456,7 @@
rpmbuild 6aa3dc9
 _sectStart          = {11}
rpmbuild 6aa3dc9
 _ulSize             = {12}
rpmbuild 6aa3dc9
 _dptPropType        = {13}""".format(
rpmbuild 6aa3dc9
-        "{0}\n                      {1}".format(self.name,
rpmbuild 6aa3dc9
-        ' '.join(['{0:02X}'.format(ord(x)) for x in self._ab[0:self._cb]])),
rpmbuild 6aa3dc9
+        "{0}\n                      {1}".format(self.name,to_hex(self._ab[0:self._cb])),
rpmbuild 6aa3dc9
         #unicode(self._ab).encode('us-ascii', 'ignore'),
rpmbuild 6aa3dc9
         '{0:04X}'.format(self._cb),
rpmbuild 6aa3dc9
         stgty_to_str(self._mse),
rpmbuild 6aa3dc9
@@ -453,7 +464,7 @@
rpmbuild 6aa3dc9
         '{0:04X}'.format(self._sidLeftSib),
rpmbuild 6aa3dc9
         '{0:04X}'.format(self._sidRightSib),
rpmbuild 6aa3dc9
         '{0:04X}'.format(self._sidChild),
rpmbuild 6aa3dc9
-        ' '.join(['{0:02X}'.format(ord(x)) for x in self._clsId]),
rpmbuild 6aa3dc9
+        to_hex(self._clsId),
rpmbuild 6aa3dc9
         '{0:04X}'.format(self._dwUserFlags),
rpmbuild 6aa3dc9
         '{0}'.format(self._time[0]),
rpmbuild 6aa3dc9
         '{0}'.format(self._time[1]),