[PATCH] Sanitize ID3v2.3 frames

Xavier Duret xaviour.maillists at gmail.com
Wed Jan 17 21:31:43 CET 2007


This patch filters out empty ID3v2.3 frames that cause taglib to
report the genre as blues. This patch has to be applied after the
"repeated genre" fix.

diff -ruN taglib.old/taglib/mpeg/id3v2/id3v2frame.cpp
taglib/taglib/mpeg/id3v2/id3v2frame.cpp
--- taglib.old/taglib/mpeg/id3v2/id3v2frame.cpp 2007-01-17
16:01:33.000000000 +0100
+++ taglib/taglib/mpeg/id3v2/id3v2frame.cpp     2007-01-17
21:09:08.000000000 +0100
@@ -326,6 +326,11 @@
     // the frame header (structure 4)

     d->frameSize = data.mid(4, 4).toUInt();
+    if ((d->frameSize == 0) ||
+        ((d->frameSize == 1) && (data.mid(10, 1) ==
textDelimiter(String::Latin1)))) {
+      d->frameID = ByteVector("JUNK",4);
+      return;
+    }

     { // read the first byte of flags
       std::bitset<8> flags(data[8]);
diff -ruN taglib.old/taglib/mpeg/id3v2/id3v2tag.cpp
taglib/taglib/mpeg/id3v2/id3v2tag.cpp
--- taglib.old/taglib/mpeg/id3v2/id3v2tag.cpp    2007-01-17
21:12:29.000000000 +0100
+++ taglib/taglib/mpeg/id3v2/id3v2tag.cpp        2007-01-17
21:01:00.000000000 +0100
@@ -437,7 +437,9 @@
     }

     frameDataPosition += frame->size() +
Frame::headerSize(d->header.majorVersion());
-    addFrame(frame);
+
+    if (!(frame->frameID() == "JUNK"))
+      addFrame(frame);
   }
 }


More information about the taglib-devel mailing list