From a6a1294944d4ce02cbb429ca1aec07ca78d79a88 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 27 May 2021 14:21:35 +0200 Subject: Tidy handling of _raw_xml. Before this if we tried to get the XML of an encrypted asset we would just get an empty string. Now we get a boost::none which means the verifier can avoid trying to check details of the XML (and instead raise a warning that you are trying to verify data that it cannot decrypt). --- src/verify.cc | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src/verify.cc') diff --git a/src/verify.cc b/src/verify.cc index 623794cc..40f7c0b6 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -728,7 +728,11 @@ verify_subtitle_asset ( /* Note: we must not use SubtitleAsset::xml_as_string() here as that will mean the data on disk * gets passed through libdcp which may clean up and therefore hide errors. */ - validate_xml (asset->raw_xml(), xsd_dtd_directory, notes); + if (asset->raw_xml()) { + validate_xml (asset->raw_xml().get(), xsd_dtd_directory, notes); + } else { + notes.push_back ({VerificationNote::Type::WARNING, VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED}); + } auto smpte = dynamic_pointer_cast(asset); if (smpte) { @@ -752,16 +756,20 @@ verify_closed_caption_asset ( /* Note: we must not use SubtitleAsset::xml_as_string() here as that will mean the data on disk * gets passed through libdcp which may clean up and therefore hide errors. */ - validate_xml (asset->raw_xml(), xsd_dtd_directory, notes); + auto raw_xml = asset->raw_xml(); + if (raw_xml) { + validate_xml (*raw_xml, xsd_dtd_directory, notes); + if (raw_xml->size() > 256 * 1024) { + notes.push_back ({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_CLOSED_CAPTION_XML_SIZE_IN_BYTES, raw_convert(raw_xml->size()), *asset->file()}); + } + } else { + notes.push_back ({VerificationNote::Type::WARNING, VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED}); + } auto smpte = dynamic_pointer_cast(asset); if (smpte) { verify_smpte_timed_text_asset (smpte, reel_asset_duration, notes); } - - if (asset->raw_xml().size() > 256 * 1024) { - notes.push_back ({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_CLOSED_CAPTION_XML_SIZE_IN_BYTES, raw_convert(asset->raw_xml().size()), *asset->file()}); - } } @@ -772,7 +780,7 @@ verify_text_timing ( int edit_rate, vector& notes, std::function)> check, - std::function)> xml, + std::function (shared_ptr)> xml, std::function)> duration ) { @@ -823,6 +831,12 @@ verify_text_timing ( continue; } + auto reel_xml = xml(reels[i]); + if (!reel_xml) { + notes.push_back ({VerificationNote::Type::WARNING, VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED}); + continue; + } + /* We need to look at instances in the XML being checked, so we can't use the subtitles * read in by libdcp's parser. */ @@ -832,7 +846,7 @@ verify_text_timing ( optional