From 38bf41a1b3fc0228ea44f69b2f145a7fa2a9aabb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 1 Jan 2023 21:14:30 +0100 Subject: Check for multiple asset IDs in an ASSETMAP during verify. --- src/verify.cc | 15 ++++++++++++++- src/verify.h | 7 ++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/verify.cc b/src/verify.cc index b554612b..3c5d180a 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -1646,7 +1646,18 @@ verify_assetmap( vector& notes ) { - validate_xml(dcp->asset_map_path().get(), xsd_dtd_directory, notes); + auto asset_map = dcp->asset_map(); + DCP_ASSERT(asset_map); + + validate_xml(asset_map->path().get(), xsd_dtd_directory, notes); + + set uuid_set; + for (auto const& asset: asset_map->assets()) { + if (!uuid_set.insert(asset.id()).second) { + notes.push_back({VerificationNote::Type::ERROR, VerificationNote::Code::DUPLICATE_ASSET_ID_IN_ASSETMAP, asset_map->id(), asset_map->path().get()}); + break; + } + } } @@ -1925,6 +1936,8 @@ dcp::note_to_string (VerificationNote note) return String::compose(" has an invalid value: %1", note.note().get()); case VerificationNote::Code::DUPLICATE_ASSET_ID_IN_PKL: return String::compose("The PKL %1 has more than one asset with the same ID", note.note().get()); + case VerificationNote::Code::DUPLICATE_ASSET_ID_IN_ASSETMAP: + return String::compose("The ASSETMAP %1 has more than one asset with the same ID", note.note().get()); } return ""; diff --git a/src/verify.h b/src/verify.h index d565abfa..e9b5c9d0 100644 --- a/src/verify.h +++ b/src/verify.h @@ -405,7 +405,12 @@ public: * note contains the PKL ID * file contains the PKL filename */ - DUPLICATE_ASSET_ID_IN_PKL + DUPLICATE_ASSET_ID_IN_PKL, + /** An ASSETMAP has more than one asset with the same ID + * note contains the ASSETMAP ID + * file contains the ASSETMAP filename + */ + DUPLICATE_ASSET_ID_IN_ASSETMAP }; VerificationNote (Type type, Code code) -- cgit v1.2.3