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

PICARD-2774: Do not fail loading files with invalid ID3 image types #2336

Merged
merged 1 commit into from
Oct 10, 2023
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 picard/coverart/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,17 @@ def __init__(self, url=None, types=None, comment='', data=None, support_types=No
self.can_be_saved_to_tags = True
self.can_be_saved_to_disk = True
self.can_be_saved_to_metadata = True
self.id3_type = id3_type
if support_types is not None:
self.support_types = support_types
if support_multi_types is not None:
self.support_multi_types = support_multi_types
if data is not None:
self.set_data(data)
try:
self.id3_type = id3_type
except ValueError:
log.warning("Invalid ID3 image type %r in %r", type, self)
self.id3_type = Id3ImageType.OTHER

@property
def source(self):
Expand Down
4 changes: 4 additions & 0 deletions test/test_coverart_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def test_id3_type_value_error(self):
with self.assertRaises(ValueError):
image.id3_type = invalid_value

def test_init_invalid_id3_type(self):
image = CoverArtImage(id3_type=255)
self.assertEqual(image.id3_type, Id3ImageType.OTHER)

def test_compare_without_type(self):
image1 = create_image(b'a', types=["front"])
image2 = create_image(b'a', types=["back"])
Expand Down
Loading