mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Ignore trailing non-data atoms when parsing MP4 covr atoms
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1110209 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
parent
2ef8fc5118
commit
3943668603
@ -209,7 +209,7 @@ MP4::Tag::parseCovr(MP4::Atom *atom, TagLib::File *file)
|
||||
int flags = data.mid(pos + 8, 4).toUInt();
|
||||
if(name != "data") {
|
||||
debug("MP4: Unexpected atom \"" + name + "\", expecting \"data\"");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
if(flags == MP4::CoverArt::PNG || flags == MP4::CoverArt::JPEG) {
|
||||
value.append(MP4::CoverArt(MP4::CoverArt::Format(flags),
|
||||
|
BIN
tests/data/covr-junk.m4a
Normal file
BIN
tests/data/covr-junk.m4a
Normal file
Binary file not shown.
@ -23,6 +23,7 @@ class TestMP4 : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testGnre);
|
||||
CPPUNIT_TEST(testCovrRead);
|
||||
CPPUNIT_TEST(testCovrWrite);
|
||||
CPPUNIT_TEST(testCovrRead2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
@ -157,6 +158,7 @@ public:
|
||||
{
|
||||
MP4::File *f = new MP4::File("data/gnre.m4a");
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::String("Ska"), f->tag()->genre());
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testCovrRead()
|
||||
@ -169,6 +171,7 @@ public:
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size());
|
||||
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size());
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testCovrWrite()
|
||||
@ -197,6 +200,19 @@ public:
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testCovrRead2()
|
||||
{
|
||||
MP4::File *f = new MP4::File("data/covr-junk.m4a");
|
||||
CPPUNIT_ASSERT(f->tag()->itemListMap().contains("covr"));
|
||||
MP4::CoverArtList l = f->tag()->itemListMap()["covr"].toCoverArtList();
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size());
|
||||
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::PNG, l[0].format());
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(79), l[0].data().size());
|
||||
CPPUNIT_ASSERT_EQUAL(MP4::CoverArt::JPEG, l[1].format());
|
||||
CPPUNIT_ASSERT_EQUAL(TagLib::uint(287), l[1].data().size());
|
||||
delete f;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4);
|
||||
|
@ -38,14 +38,16 @@ inline void deleteFile(const string &filename)
|
||||
class ScopedFileCopy
|
||||
{
|
||||
public:
|
||||
ScopedFileCopy(const string &filename, const string &ext)
|
||||
ScopedFileCopy(const string &filename, const string &ext, bool deleteFile=true)
|
||||
{
|
||||
m_deleteFile = deleteFile;
|
||||
m_filename = copyFile(filename, ext);
|
||||
}
|
||||
|
||||
~ScopedFileCopy()
|
||||
{
|
||||
deleteFile(m_filename);
|
||||
if(m_deleteFile)
|
||||
deleteFile(m_filename);
|
||||
}
|
||||
|
||||
string fileName()
|
||||
@ -54,5 +56,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_deleteFile;
|
||||
string m_filename;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user