]> granicus.if.org Git - taglib/commitdiff
Remove duplicate tags when saving AIFF files.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Sun, 22 Nov 2015 12:03:33 +0000 (21:03 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Sun, 22 Nov 2015 12:03:33 +0000 (21:03 +0900)
Just the same way as WAV already does.

NEWS
taglib/riff/aiff/aifffile.cpp
tests/test_aiff.cpp

diff --git a/NEWS b/NEWS
index 1c0d83838068b3c533b0ae66d89db7d2a506fc9d..baf214b2ca4416c478ee039d94365e75e18e10d3 100644 (file)
--- 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.
index 35eedd8e350d1863f8156df3dec5ba7cd27008f0..c5c7f881bfce2ef488005b667e474ff13e67d760 100644 (file)
@@ -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 {
index 386c7686608b4834fbdc14c59ca9a319ef227803..830b6787abffcbd5a84eedc45661c98870af933e 100644 (file)
@@ -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()