diff --git a/oletools/record_base.py b/oletools/record_base.py index 76fcb5e..7a2900a 100644 --- a/oletools/record_base.py +++ b/oletools/record_base.py @@ -258,15 +258,25 @@ class OleRecordBase(object): self.size = size self.pos = pos self.data = data - self.parse(more_data) + self.finish_constructing(more_data) - def parse(self, more_data): + def finish_constructing(self, more_data): """ finish constructing this record Can save more_data from OleRecordStream.read_record_head and/or parse data (if it was read). Base implementation, does nothing. To be overwritten in subclasses. + + Implementations should take into account that self.data may be None. + Should create the same attributes, whether data is present or not. Eg:: + + def finish_constructing(self, more_data): + self.more = more_data + self.attr1 = None + self.attr2 = None + if self.data: + self.attr1, self.attr2 = struct.unpack('