]> granicus.if.org Git - taglib/commitdiff
Don't stop parsing an ID3v2 SYLT frame when its description is empty.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Mon, 14 Mar 2016 11:35:09 +0000 (20:35 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Mon, 14 Mar 2016 11:35:09 +0000 (20:35 +0900)
NEWS
taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp
tests/test_id3v2.cpp

diff --git a/NEWS b/NEWS
index 7509d4e2d703488d93b206d6935310f4f68d075e..2defc51a17f193fd1f031df0408a42fd720fa1de 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ TagLib 1.11 (Mar 4, 2016)
 =========================
 
  * Fixed reading APE items with long keys.
+ * Fixed reading ID3v2 SYLT frames when description is empty.
 
 1.11 BETA 2:
 
index 4fb2e15a6a4ec2927fe2a63fa6c9eade60fafed2..c3b50c7ec3644bb1ecf3b8b610e5d2e25710e78d 100644 (file)
@@ -158,7 +158,7 @@ void SynchronizedLyricsFrame::parseFields(const ByteVector &data)
   int pos = 6;
 
   d->description = readStringField(data, d->textEncoding, &pos);
-  if(d->description.isEmpty())
+  if(pos == 6)
     return;
 
   /*
index a560658b5227a10695f57d86abaf3714267725a5..d5ba9f29f1889b585976c88ef15dbc626ae2b260 100644 (file)
@@ -94,6 +94,7 @@ class TestID3v2 : public CppUnit::TestFixture
   CPPUNIT_TEST(testParseOwnershipFrame);
   CPPUNIT_TEST(testRenderOwnershipFrame);
   CPPUNIT_TEST(testParseSynchronizedLyricsFrame);
+  CPPUNIT_TEST(testParseSynchronizedLyricsFrameWithEmptyDescritpion);
   CPPUNIT_TEST(testRenderSynchronizedLyricsFrame);
   CPPUNIT_TEST(testParseEventTimingCodesFrame);
   CPPUNIT_TEST(testRenderEventTimingCodesFrame);
@@ -527,6 +528,35 @@ public:
     CPPUNIT_ASSERT_EQUAL((unsigned int)4567, stl[1].time);
   }
 
+  void testParseSynchronizedLyricsFrameWithEmptyDescritpion()
+  {
+    ID3v2::SynchronizedLyricsFrame f(
+      ByteVector("SYLT"                      // Frame ID
+                 "\x00\x00\x00\x21"          // Frame size
+                 "\x00\x00"                  // Frame flags
+                 "\x00"                      // Text encoding
+                 "eng"                       // Language
+                 "\x02"                      // Time stamp format
+                 "\x01"                      // Content type
+                 "\x00"                      // Content descriptor
+                 "Example\x00"               // 1st text
+                 "\x00\x00\x04\xd2"          // 1st time stamp
+                 "Lyrics\x00"                // 2nd text
+                 "\x00\x00\x11\xd7", 40));   // 2nd time stamp
+    CPPUNIT_ASSERT_EQUAL(String::Latin1, f.textEncoding());
+    CPPUNIT_ASSERT_EQUAL(ByteVector("eng", 3), f.language());
+    CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::AbsoluteMilliseconds,
+                         f.timestampFormat());
+    CPPUNIT_ASSERT_EQUAL(ID3v2::SynchronizedLyricsFrame::Lyrics, f.type());
+    CPPUNIT_ASSERT(f.description().isEmpty());
+    ID3v2::SynchronizedLyricsFrame::SynchedTextList stl = f.synchedText();
+    CPPUNIT_ASSERT_EQUAL((unsigned int)2, stl.size());
+    CPPUNIT_ASSERT_EQUAL(String("Example"), stl[0].text);
+    CPPUNIT_ASSERT_EQUAL((unsigned int)1234, stl[0].time);
+    CPPUNIT_ASSERT_EQUAL(String("Lyrics"), stl[1].text);
+    CPPUNIT_ASSERT_EQUAL((unsigned int)4567, stl[1].time);
+  }
+
   void testRenderSynchronizedLyricsFrame()
   {
     ID3v2::SynchronizedLyricsFrame f;