Cleanup: extract verify_pkl().
authorCarl Hetherington <cth@carlh.net>
Sat, 31 Dec 2022 20:59:29 +0000 (21:59 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 7 Jan 2023 21:39:54 +0000 (22:39 +0100)
src/verify.cc

index eb44fc25fd10ad6363052f21f2117936e34b3757..2cfd283e85d3db79274459bfd0c969b239736a56 100644 (file)
@@ -1606,6 +1606,26 @@ verify_cpl(
 }
 
 
+static
+void
+verify_pkl(
+       shared_ptr<const DCP> dcp,
+       shared_ptr<const PKL> pkl,
+       boost::filesystem::path xsd_dtd_directory,
+       vector<VerificationNote>& notes
+       )
+{
+       validate_xml(pkl->file().get(), xsd_dtd_directory, notes);
+       if (pkl_has_encrypted_assets(dcp, pkl)) {
+               cxml::Document doc("PackingList");
+               doc.read_file(pkl->file().get());
+               if (!doc.optional_node_child("Signature")) {
+                       notes.push_back({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::UNSIGNED_PKL_WITH_ENCRYPTED_CONTENT, pkl->id(), pkl->file().get()});
+               }
+       }
+}
+
+
 vector<VerificationNote>
 dcp::verify (
        vector<boost::filesystem::path> directories,
@@ -1666,15 +1686,8 @@ dcp::verify (
                }
 
                for (auto pkl: dcp->pkls()) {
-                       stage ("Checking PKL", pkl->file());
-                       validate_xml (pkl->file().get(), *xsd_dtd_directory, notes);
-                       if (pkl_has_encrypted_assets(dcp, pkl)) {
-                               cxml::Document doc ("PackingList");
-                               doc.read_file (pkl->file().get());
-                               if (!doc.optional_node_child("Signature")) {
-                                       notes.push_back ({VerificationNote::Type::BV21_ERROR, VerificationNote::Code::UNSIGNED_PKL_WITH_ENCRYPTED_CONTENT, pkl->id(), pkl->file().get()});
-                               }
-                       }
+                       stage("Checking PKL", pkl->file());
+                       verify_pkl(dcp, pkl, *xsd_dtd_directory, notes);
                }
 
                if (dcp->asset_map_path()) {