Allow DCP reading to continue even with empty <Path> nodes in ASSETMAP. v1.6.11
authorCarl Hetherington <cth@carlh.net>
Fri, 30 Aug 2019 21:28:06 +0000 (22:28 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 11 Nov 2019 20:24:29 +0000 (21:24 +0100)
src/dcp.cc
src/exceptions.cc
src/exceptions.h

index 5d908530edc43561f5e8d1231a1f4837fbd6c4b4..69875235271717f6853f910d8acad755e314ddb9 100644 (file)
@@ -173,7 +173,12 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx
                _pkls.push_back (shared_ptr<PKL>(new PKL(_directory / i)));
        }
 
-       /* Read all the assets from the asset map */
+       /* Now we have:
+            paths - files in the DCP that are not PKLs.
+            _pkls - PKL objects for each PKL.
+
+          Read all the assets from the asset map.
+        */
 
        /* Make a list of non-CPL/PKL assets so that we can resolve the references
           from the CPLs.
@@ -183,11 +188,20 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx
        for (map<string, boost::filesystem::path>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
                boost::filesystem::path path = _directory / i->second;
 
-               if (!boost::filesystem::exists (path)) {
+               if (i->second.empty()) {
+                       /* I can't see how this is valid, but it's
+                          been seen in the wild with a DCP that
+                          claims to come from ClipsterDCI 5.10.0.5.
+                       */
+                       survivable_error (keep_going, errors, EmptyAssetPathError(i->first));
+               }
+
+               if (i->second.empty() || !boost::filesystem::exists(path)) {
                        survivable_error (keep_going, errors, MissingAssetError (path));
                        continue;
                }
 
+               /* Find the <Type> for this asset from the PKL that contains the asset */
                optional<string> pkl_type;
                BOOST_FOREACH (shared_ptr<PKL> j, _pkls) {
                        pkl_type = j->type(i->first);
index 7516d0858577050f1f29ce82d9f57b79d715dd66..0b8978dc6528c53ff360a576e6f2048789ba3485 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -129,3 +129,12 @@ MissingSubtitleImageError::MissingSubtitleImageError (string id)
 {
 
 }
+
+/** The <Path> in the ASSETMAP is empty for asset.  I can't see how this is valid,
+    but it's been seen in the wild with a DCP that claims to come from ClipsterDCI 5.10.0.5.
+ */
+EmptyAssetPathError::EmptyAssetPathError (string id)
+       : DCPReadError (String::compose("Asset map path is empty for asset %1", id))
+{
+
+}
index 65271c1618fc233af9c3ed18710abef97721e90f..1e9bd2d7cad23e07d75d739cc1f3696d2ddc8db7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -228,6 +228,12 @@ public:
        MissingSubtitleImageError (std::string id);
 };
 
+class EmptyAssetPathError : public DCPReadError
+{
+public:
+       EmptyAssetPathError (std::string id);
+};
+
 }
 
 #endif