Do not miss frames when an extended header is present (#1081)

This commit is contained in:
Urs Fleisch 2023-03-18 08:08:37 +01:00 committed by GitHub
parent e21640bf10
commit 97203503b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View File

@ -784,7 +784,6 @@ void ID3v2::Tag::parse(const ByteVector &origData)
d->extendedHeader->setData(data);
if(d->extendedHeader->size() <= data.size()) {
frameDataPosition += d->extendedHeader->size();
frameDataLength -= d->extendedHeader->size();
}
}

Binary file not shown.

View File

@ -34,6 +34,7 @@
#include <mpegproperties.h>
#include <xingheader.h>
#include <mpegheader.h>
#include <id3v2extendedheader.h>
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@ -66,6 +67,7 @@ class TestMPEG : public CppUnit::TestFixture
CPPUNIT_TEST(testEmptyID3v1);
CPPUNIT_TEST(testEmptyAPE);
CPPUNIT_TEST(testIgnoreGarbage);
CPPUNIT_TEST(testExtendedHeader);
CPPUNIT_TEST_SUITE_END();
public:
@ -535,6 +537,28 @@ public:
}
}
void testExtendedHeader()
{
const ScopedFileCopy copy("extended-header", ".mp3");
{
MPEG::File f(copy.fileName().c_str());
CPPUNIT_ASSERT(f.isValid());
CPPUNIT_ASSERT(f.hasID3v2Tag());
ID3v2::Tag *tag = f.ID3v2Tag();
ID3v2::ExtendedHeader *ext = tag->extendedHeader();
CPPUNIT_ASSERT(ext);
CPPUNIT_ASSERT_EQUAL(12U, ext->size());
CPPUNIT_ASSERT_EQUAL(String("Druids"), tag->title());
CPPUNIT_ASSERT_EQUAL(String("Excelsis"), tag->artist());
CPPUNIT_ASSERT_EQUAL(String("Vo Chrieger U Drache"), tag->album());
CPPUNIT_ASSERT_EQUAL(2013U, tag->year());
CPPUNIT_ASSERT_EQUAL(String("Folk/Power Metal"), tag->genre());
CPPUNIT_ASSERT_EQUAL(3U, tag->track());
CPPUNIT_ASSERT_EQUAL(String("2013"),
f.properties().value("ORIGINALDATE").front());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestMPEG);