RIFF: Report unknown INFO fields by their ID in properties() (#1471)

RIFF::Info::Tag::properties() passed the result of the failed property
key lookup, an empty string, to addUnsupportedData() instead of the
field ID. An INFO chunk with a field that has no property mapping
therefore reported an empty entry in unsupportedData(), and passing that
list to removeUnsupportedProperties(), which erases by ID, removed
nothing.

Report the field ID instead, decoded as Latin-1 to match how
removeUnsupportedProperties() encodes it.

The new test sets a mapped field (INAM) and an unmapped one (ITRK),
checks that unsupportedData() is ["ITRK"], and that
removeUnsupportedProperties() with that list removes ITRK and keeps
INAM.
This commit is contained in:
Ryan Francesconi
2026-10-28 17:12:02 +01:00
committed by GitHub
parent 1ae164e382
commit 9d09f9b413
2 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -204,7 +204,7 @@ PropertyMap RIFF::Info::Tag::properties() const
props[key].append(val);
}
else {
props.addUnsupportedData(key);
props.addUnsupportedData(String(id, String::Latin1));
}
}
return props;
+17
View File
@@ -27,6 +27,7 @@
#include <cstdio>
#include "infotag.h"
#include "tpropertymap.h"
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@@ -38,6 +39,7 @@ class TestInfoTag : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(TestInfoTag);
CPPUNIT_TEST(testTitle);
CPPUNIT_TEST(testNumericFields);
CPPUNIT_TEST(testUnsupportedProperties);
CPPUNIT_TEST_SUITE_END();
public:
@@ -70,6 +72,21 @@ public:
CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(1234), tag.year());
CPPUNIT_ASSERT_EQUAL(String("1234"), tag.fieldText("ICRD"));
}
void testUnsupportedProperties()
{
RIFF::Info::Tag tag;
tag.setFieldText("INAM", "Title");
tag.setFieldText("ITRK", "7");
const PropertyMap props = tag.properties();
CPPUNIT_ASSERT_EQUAL(StringList("ITRK"), props.unsupportedData());
CPPUNIT_ASSERT_EQUAL(StringList("Title"), props["TITLE"]);
tag.removeUnsupportedProperties(props.unsupportedData());
CPPUNIT_ASSERT(!tag.fieldListMap().contains("ITRK"));
CPPUNIT_ASSERT_EQUAL(String("Title"), tag.fieldText("INAM"));
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestInfoTag);