mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Check invalid Unicode APE keys properly.
This commit is contained in:
parent
9d58e9f8e8
commit
499f6db977
@ -299,7 +299,7 @@ bool APE::Tag::checkKey(const String &key)
|
||||
if(key.size() < MinKeyLength || key.size() > MaxKeyLength)
|
||||
return false;
|
||||
|
||||
return isKeyValid(key.data(String::Latin1));
|
||||
return isKeyValid(key.data(String::UTF8));
|
||||
}
|
||||
|
||||
APE::Footer *APE::Tag::footer() const
|
||||
|
@ -114,18 +114,21 @@ public:
|
||||
PropertyMap properties;
|
||||
properties["A"] = String("invalid key: one character");
|
||||
properties["MP+"] = String("invalid key: forbidden string");
|
||||
properties[L"\x1234\x3456"] = String("invalid key: Unicode");
|
||||
properties["A B~C"] = String("valid key: space and tilde");
|
||||
properties["ARTIST"] = String("valid key: normal one");
|
||||
|
||||
APE::Tag tag;
|
||||
PropertyMap unsuccessful = tag.setProperties(properties);
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2, unsuccessful.size());
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, unsuccessful.size());
|
||||
CPPUNIT_ASSERT(unsuccessful.contains("A"));
|
||||
CPPUNIT_ASSERT(unsuccessful.contains("MP+"));
|
||||
CPPUNIT_ASSERT(unsuccessful.contains(L"\x1234\x3456"));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)2, tag.itemListMap().size());
|
||||
tag.addValue("VALID KEY", "Test Value 1");
|
||||
tag.addValue("INVALID KEY \x7f", "Test Value 2");
|
||||
tag.addValue(L"INVALID KEY \x1234\x3456", "Test Value 3");
|
||||
CPPUNIT_ASSERT_EQUAL((unsigned int)3, tag.itemListMap().size());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user