summaryrefslogtreecommitdiff
path: root/src/verify.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-05-27 14:21:35 +0200
committerCarl Hetherington <cth@carlh.net>2021-05-27 14:25:17 +0200
commita6a1294944d4ce02cbb429ca1aec07ca78d79a88 (patch)
tree0122b12b7488a7471a0764a3f1e857c0cc3584b8 /src/verify.cc
parent8c27355abdac31c38c2fd5f41e36097dd5360422 (diff)
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).
Diffstat (limited to 'src/verify.cc')
-rw-r--r--src/verify.cc34
1 files changed, 25 insertions, 9 deletions
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<const SMPTESubtitleAsset>(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<string>(raw_xml->size()), *asset->file()});
+ }
+ } else {
+ notes.push_back ({VerificationNote::Type::WARNING, VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED});
+ }
auto smpte = dynamic_pointer_cast<const SMPTESubtitleAsset>(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<string>(asset->raw_xml().size()), *asset->file()});
- }
}
@@ -772,7 +780,7 @@ verify_text_timing (
int edit_rate,
vector<VerificationNote>& notes,
std::function<bool (shared_ptr<Reel>)> check,
- std::function<string (shared_ptr<Reel>)> xml,
+ std::function<optional<string> (shared_ptr<Reel>)> xml,
std::function<int64_t (shared_ptr<Reel>)> 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 <Subtitle> 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<Time> start_time;
try {
doc = make_shared<cxml::Document>("SubtitleReel");
- doc->read_string (xml(reels[i]));
+ doc->read_string (*reel_xml);
tcr = doc->number_child<int>("TimeCodeRate");
auto start_time_string = doc->optional_string_child("StartTime");
if (start_time_string) {
@@ -840,7 +854,7 @@ verify_text_timing (
}
} catch (...) {
doc = make_shared<cxml::Document>("DCSubtitle");
- doc->read_string (xml(reels[i]));
+ doc->read_string (*reel_xml);
}
parse (doc, tcr, start_time, edit_rate, i == 0);
auto end = reel_offset + duration(reels[i]);
@@ -1605,6 +1619,8 @@ dcp::note_to_string (VerificationNote note)
DCP_ASSERT (parts.size() == 2);
return String::compose("The reel duration of some timed text (%1) is not the same as the ContainerDuration of its MXF (%2).", parts[0], parts[1]);
}
+ case VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED:
+ return "Some aspect of this DCP could not be checked because it is encrypted.";
}
return "";