diff --git a/taglib/mp4/mp4atom.cpp b/taglib/mp4/mp4atom.cpp index 0a1eb587..4c558526 100644 --- a/taglib/mp4/mp4atom.cpp +++ b/taglib/mp4/mp4atom.cpp @@ -95,13 +95,6 @@ MP4::Atom::Atom(File *file) } d->name = header.mid(4, 4); - for(int i = 0; i < 4; ++i) { - if(const char ch = d->name.at(i); (ch < ' ' || ch > '~') && ch != '\251') { - debug("MP4: Invalid atom type"); - d->length = 0; - file->seek(0, File::End); - } - } for(auto c : containers) { if(d->name == c) { diff --git a/tests/data/nonprintable-atom-type.m4a b/tests/data/nonprintable-atom-type.m4a new file mode 100644 index 00000000..bf7858a0 Binary files /dev/null and b/tests/data/nonprintable-atom-type.m4a differ diff --git a/tests/test_mp4.cpp b/tests/test_mp4.cpp index c37e4e04..ea4a8d0a 100644 --- a/tests/test_mp4.cpp +++ b/tests/test_mp4.cpp @@ -101,6 +101,7 @@ class TestMP4 : public CppUnit::TestFixture CPPUNIT_TEST(testRemoveMetadata); CPPUNIT_TEST(testNonFullMetaAtom); CPPUNIT_TEST(testItemFactory); + CPPUNIT_TEST(testNonPrintableAtom); CPPUNIT_TEST_SUITE_END(); public: @@ -847,6 +848,25 @@ public: CPPUNIT_ASSERT_EQUAL(StringList("456"), properties.value("TESTINTEGER")); } } + + void testNonPrintableAtom() + { + ScopedFileCopy copy("nonprintable-atom-type", ".m4a"); + { + MP4::File f(copy.fileName().c_str()); + CPPUNIT_ASSERT(f.isValid()); + CPPUNIT_ASSERT_EQUAL(1, f.audioProperties()->channels()); + CPPUNIT_ASSERT_EQUAL(32000, f.audioProperties()->sampleRate()); + f.tag()->setTitle("TITLE"); + f.save(); + } + { + MP4::File f(copy.fileName().c_str()); + CPPUNIT_ASSERT(f.isValid()); + CPPUNIT_ASSERT(f.hasMP4Tag()); + CPPUNIT_ASSERT_EQUAL(String("TITLE"), f.tag()->title()); + } + } }; CPPUNIT_TEST_SUITE_REGISTRATION(TestMP4);