diff --git a/NEWS b/NEWS index 1c0d8383..baf214b2 100644 --- a/NEWS +++ b/NEWS @@ -5,7 +5,8 @@ * Added String::clear(). * Added alternative functions to XiphComment::removeField(). * Better handling of duplicate ID3v2 tags in all kinds of files. - * Better handling of duplicate tags in WAV files. + * Better handling of duplicate tag chunks in WAV files. + * Better handling of duplicate tag chunks in AIFF files. * Fixed crash when calling File::properties() after strip(). * Fixed possible file corruptions when saving ASF files. * Fixed updating the comment field of Vorbis comments. diff --git a/taglib/riff/aiff/aifffile.cpp b/taglib/riff/aiff/aifffile.cpp index 35eedd8e..c5c7f881 100644 --- a/taglib/riff/aiff/aifffile.cpp +++ b/taglib/riff/aiff/aifffile.cpp @@ -39,7 +39,6 @@ public: FilePrivate() : properties(0), tag(0), - tagChunkID("ID3 "), hasID3v2(false) {} ~FilePrivate() @@ -50,7 +49,6 @@ public: Properties *properties; ID3v2::Tag *tag; - ByteVector tagChunkID; bool hasID3v2; }; @@ -117,7 +115,10 @@ bool RIFF::AIFF::File::save() return false; } - setChunkData(d->tagChunkID, d->tag->render()); + removeChunk("ID3 "); + removeChunk("id3 "); + + setChunkData("ID3 ", d->tag->render()); d->hasID3v2 = true; return true; @@ -139,7 +140,6 @@ void RIFF::AIFF::File::read(bool readProperties) if(name == "ID3 " || name == "id3 ") { if(!d->tag) { d->tag = new ID3v2::Tag(this, chunkOffset(i)); - d->tagChunkID = name; d->hasID3v2 = true; } else { diff --git a/tests/test_aiff.cpp b/tests/test_aiff.cpp index 386c7686..830b6787 100644 --- a/tests/test_aiff.cpp +++ b/tests/test_aiff.cpp @@ -77,13 +77,18 @@ public: void testDuplicateID3v2() { - RIFF::AIFF::File f(TEST_FILE_PATH_C("duplicate_id3v2.aiff")); + ScopedFileCopy copy("duplicate_id3v2", ".aiff"); - // duplicate_id3v2.aiff has duplicate ID3v2 tags. + // duplicate_id3v2.aiff has duplicate ID3v2 tag chunks. // title() returns "Title2" if can't skip the second tag. + RIFF::AIFF::File f(copy.fileName().c_str()); CPPUNIT_ASSERT(f.hasID3v2Tag()); CPPUNIT_ASSERT_EQUAL(String("Title1"), f.tag()->title()); + + f.save(); + CPPUNIT_ASSERT_EQUAL(7030L, f.length()); + CPPUNIT_ASSERT_EQUAL(-1L, f.find("Title2")); } void testFuzzedFile1()