Don't stop parsing an ID3v2 SYLT frame when its description is empty.

This commit is contained in:
Tsuda Kageyu
2016-03-14 20:35:09 +09:00
parent 7d270a7e20
commit b2a6768704
3 changed files with 32 additions and 1 deletions

1
NEWS
View File

@ -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:

View 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;
/*

View 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;