Fixed IndexError on reading embedded cover art with invalid cover type

This commit is contained in:
Matthias Kiefer 2015-01-23 13:44:08 +01:00
parent 268dcb0008
commit b16898743d
3 changed files with 9 additions and 1 deletions

View file

@ -326,7 +326,11 @@ class Image(object):
self.data = data
self.desc = desc
if isinstance(type, int):
type = list(ImageType)[type]
try:
type = list(ImageType)[type]
except IndexError:
log.warn("ignoring unknown image type index {}", type)
type = ImageType.other
self.type = type
@property

BIN
test/rsrc/image_unknown_type.mp3 Executable file

Binary file not shown.

View file

@ -730,6 +730,10 @@ class MP3Test(ReadWriteTestBase, PartialTestMixin,
'channels': 1,
}
def test_unknown_apic_type(self):
mediafile = self._mediafile_fixture('image_unknown_type')
self.assertEqual(mediafile.images[0].type, ImageType.other)
class MP4Test(ReadWriteTestBase, PartialTestMixin,
ImageStructureTestMixin, unittest.TestCase):