Merge pull request #1260 from kiefermat/index_error_on_unknown_cover_type

Fixed IndexError on reading embedded cover art with invalid cover type
This commit is contained in:
Adrian Sampson 2015-01-23 10:34:10 -08:00
commit 3336f56a6e
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):