Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed IndexError on reading embedded cover art with invalid cover type #1260

Merged
merged 1 commit into from
Jan 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion beets/mediafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,11 @@ def __init__(self, data, desc=None, type=None):
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
Expand Down
Binary file added test/rsrc/image_unknown_type.mp3
Binary file not shown.
4 changes: 4 additions & 0 deletions test/test_mediafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down