Commit f4da38627108fe1535942a5724c34b2f476d4549

Authored by Pavol Plaskoň
1 parent 09d42b43

Fix ignoring of whitespace after \bin for Python 2 and 3.

In my previous commit
https://github.com/decalage2/oletools/pull/316/commits/09d42b43bcbac34a0c73c694f16eda43975026d8
I fixed this bug for Python3 but I've made a mistake when testing with Python2.

Now, both Python versions should ignore whitespace after \bin correctly.

Python2:
>>> data = b' foo'
>>> index = 0
>>> ord(data[index:index + 1])
32
>>> ord(' ')
32

Python3
>>> data = b' foo'
>>> index = 0
>>> ord(data[index:index + 1])
32
>>> ord(' ')
32
Showing 1 changed file with 1 additions and 1 deletions
oletools/rtfobj.py
@@ -578,7 +578,7 @@ class RtfParser(object): @@ -578,7 +578,7 @@ class RtfParser(object):
578 # it should be treated as a null length: 578 # it should be treated as a null length:
579 binlen=0 579 binlen=0
580 # ignore optional space after \bin 580 # ignore optional space after \bin
581 - if self.data[self.index] == ord(' '): 581 + if ord(self.data[self.index:self.index + 1]) == ord(' '):
582 log.debug('\\bin: ignoring whitespace before data') 582 log.debug('\\bin: ignoring whitespace before data')
583 self.index += 1 583 self.index += 1
584 log.debug('\\bin: reading %d bytes of binary data' % binlen) 584 log.debug('\\bin: reading %d bytes of binary data' % binlen)