Skip to content

Commit fc6a3e7

Browse files
drewpianare
andauthored
Fixes for exif in heic files from my Note10+ (#127)
* Fix logic for missing a box parser * expect_parse skips any number of nonmatching boxes * _parse_iloc was missing the data_reference_index field Co-authored-by: ianaré sévi <[email protected]>
1 parent 55b91ee commit fc6a3e7

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

exifread/heic.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ def get(self, nbytes):
4949
read = self.file_handle.read(nbytes)
5050
if not read:
5151
raise EOFError
52+
if len(read) != nbytes:
53+
msg = "get(nbytes={nbytes}) found {read} bytes at postion {pos}".format(
54+
nbytes=nbytes,
55+
read=len(read),
56+
pos=self.file_handle.tell()
57+
)
58+
raise BadSize(msg)
5259
return read
5360

5461
def get16(self):
@@ -117,10 +124,11 @@ def skip(self, box):
117124
self.file_handle.seek(box.after)
118125

119126
def expect_parse(self, name):
120-
box = self.next_box()
121-
if box.name == name:
122-
return self.parse_box(box)
123-
raise WrongBox(name, box.name)
127+
while True:
128+
box = self.next_box()
129+
if box.name == name:
130+
return self.parse_box(box)
131+
self.skip(box)
124132

125133
def get_parser(self, box):
126134
method = 'parse_%s' % box.name
@@ -210,7 +218,9 @@ def parse_iloc(self, box):
210218
raise BoxVersion(2, box.version)
211219
if box.version in (1, 2):
212220
# ignore construction_method
213-
_ = self.get16()
221+
self.get16()
222+
# ignore data_reference_index
223+
self.get16()
214224
box.base_offset = self.get_int(box.base_offset_size)
215225
extent_count = self.get16()
216226
extents = []

0 commit comments

Comments
 (0)