From 394366860380d20cd1cbf60975d66d89c256d971 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= Date: Fri, 2 Apr 2010 12:14:32 +0000 Subject: [PATCH] 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 --- taglib/mp4/mp4tag.cpp | 2 +- tests/data/covr-junk.m4a | Bin 0 -> 5108 bytes tests/test_mp4.cpp | 16 ++++++++++++++++ tests/utils.h | 7 +++++-- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tests/data/covr-junk.m4a diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp index ecffbef4..f8acc87a 100644 --- a/taglib/mp4/mp4tag.cpp +++ b/taglib/mp4/mp4tag.cpp @@ -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), diff --git a/tests/data/covr-junk.m4a b/tests/data/covr-junk.m4a new file mode 100644 index 0000000000000000000000000000000000000000..ac80cb29d2585e9d728a86b5027973690f51d174 GIT binary patch literal 5108 zcmeHK-)qxw5Wgf{e{Jnj?c7gBwr+EX>$Gmjbg*@+oe|w+6ciC=)}*ekX-1O`6_MhT zBErBui7@d&7>dvOAXFF#J}Wo};-i0nuM+Rl)U8DXVW1EBw8`D~^8Mc3_ru*cEdaD+ zj2lbp(ohT#B(u7v0@S@$Wy$#B0?1|OGm?}Rjz(ic02A;~aK&J%3&d5n6(U7PaY%3~ z!RZ303;u^L00>4@Oh~~@2qLmBtE0;&^7V@oR5oF<*bA* z1XZrtFT6+qd%I-2?^=*^g-R%0Th3Q>TXOHzY(9enURTSG><2w^+1?=+6naje6dRTc zIiaj`_jO}Fhx%3B&@Ix-cDR6VR7#Gpvn>{QGGKayV~SoTk3;gh(cnTE9&Z9@!yw-P z>gVgw!tUeUC>Y{f&<(@l8+975<02Fkf-T{-hH2a+gN-LB(HZ!h%i-W3)j&ViWEx`= zsAj1h4%?E7x5L)4w$mEw1hNY_^$h?g;_xGl)77<)eyrNZ9w7K4%d#P%Y*!VM7OHw5 z&x?Yzv_$P%0lSvX=?0FT4j@o=sETAA5NS<~(qtu?O)cjYYPxVD|C#_*%5;j@!t9Aser%Dk7__XotQ;Q6tiBs|M>8T(mo(2 z;;HM8)3?^&mk^tDD*=Rj%*E$-w=KrSQ`3o;6IbqFm_gfp09S(f$@~iZnWUHmhG9U) z518992|l;S>v8+MUa#Nps}D9e1_Oa$N4P1}+}#<8bae_s@1fy=-h;7zL5PkG#*UAS zj*j*WOeEtclEWuQN5~1|_xpnl!S=?+_K`lJZ{)9GmLTNC{jwa>4Qz zz6%~ShxuA7&}7jreQ|_4eI$ yky3O+h!>2kRcc)uhDNNn?w*p2$0zN7TJB4kf}&tz4jcv?1{?+)1{?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); diff --git a/tests/utils.h b/tests/utils.h index ad61d284..dece293f 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -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; }; -- 2.40.0