mirror of
https://github.com/taglib/taglib.git
synced 2026-04-12 17:09:50 -04:00
Move MPEG check to end of content-based detection (#1319)
MPEG::File::isSupported() scans for frame sync bytes that can appear in other files, causing them to be misidentified as MP3. This also includes a test with such a file.
This commit is contained in:
@ -246,8 +246,7 @@ namespace
|
||||
{
|
||||
File *file = nullptr;
|
||||
|
||||
if(MPEG::File::isSupported(stream))
|
||||
file = new MPEG::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||
if(false);
|
||||
#ifdef TAGLIB_WITH_VORBIS
|
||||
else if(Ogg::Vorbis::File::isSupported(stream))
|
||||
file = new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||
@ -300,6 +299,8 @@ namespace
|
||||
else if(Matroska::File::isSupported(stream))
|
||||
file = new Matroska::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||
#endif
|
||||
else if(MPEG::File::isSupported(stream))
|
||||
file = new MPEG::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||
|
||||
// isSupported() only does a quick check, so double check the file here.
|
||||
|
||||
|
||||
BIN
tests/data/mpeg-sync-flac.flac
Normal file
BIN
tests/data/mpeg-sync-flac.flac
Normal file
Binary file not shown.
@ -167,6 +167,7 @@ class TestFileRefDetectByContent : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testSilence44SFlac);
|
||||
CPPUNIT_TEST(testSinewaveFlac);
|
||||
CPPUNIT_TEST(testZeroSizedPaddingFlac);
|
||||
CPPUNIT_TEST(testFLACWithMPEGSyncBytes);
|
||||
// Ogg::Speex::File
|
||||
CPPUNIT_TEST(testEmptySpx);
|
||||
// Ogg::Opus::File
|
||||
@ -326,6 +327,9 @@ public:
|
||||
void testZeroSizedPaddingFlac() {
|
||||
detectByContent<FLAC::File>("zero-sized-padding.flac");
|
||||
}
|
||||
void testFLACWithMPEGSyncBytes() {
|
||||
detectByContent<FLAC::File>("mpeg-sync-flac.flac");
|
||||
}
|
||||
|
||||
// -- Ogg::Speex::File --
|
||||
void testEmptySpx() { detectByContent<Ogg::Speex::File>("empty.spx"); }
|
||||
|
||||
Reference in New Issue
Block a user