summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-04-26 16:42:43 +0200
committerCarl Hetherington <cth@carlh.net>2023-04-26 16:42:47 +0200
commit928b10e8f4195c29a31fe643e38fb00b6c1b8953 (patch)
treec09ebb9b816b7840312f12c8ef80a4fcce63cf11 /src
parentaae2f02038b1cd36e1b1bf2e4f0821e86cff2841 (diff)
Give better errors when invalid urn:uuid: strings are found (DoM #2521).
Diffstat (limited to 'src')
-rw-r--r--src/exceptions.cc7
-rw-r--r--src/exceptions.h8
-rw-r--r--src/util.cc5
-rw-r--r--src/verify.cc4
4 files changed, 22 insertions, 2 deletions
diff --git a/src/exceptions.cc b/src/exceptions.cc
index 96a9a696..e86a3b89 100644
--- a/src/exceptions.cc
+++ b/src/exceptions.cc
@@ -205,3 +205,10 @@ InconsistentValidityPeriodError::InconsistentValidityPeriodError()
}
+
+BadURNUUIDError::BadURNUUIDError(string bad_id)
+ : runtime_error(String::compose("Badly-formed URN UUID %1", bad_id))
+{
+
+}
+
diff --git a/src/exceptions.h b/src/exceptions.h
index 99e55b28..8d85f02a 100644
--- a/src/exceptions.h
+++ b/src/exceptions.h
@@ -323,6 +323,14 @@ public:
InconsistentValidityPeriodError();
};
+
+class BadURNUUIDError : public std::runtime_error
+{
+public:
+ BadURNUUIDError(std::string bad_id);
+};
+
+
}
diff --git a/src/util.cc b/src/util.cc
index 9cc35ad6..bbfcd30e 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -314,7 +314,10 @@ dcp::find_child (xmlpp::Node const * node, string name)
string
dcp::remove_urn_uuid (string raw)
{
- DCP_ASSERT (raw.substr(0, 9) == "urn:uuid:");
+ if (raw.substr(0, 9) != "urn:uuid:") {
+ throw BadURNUUIDError(raw);
+ }
+
return raw.substr (9);
}
diff --git a/src/verify.cc b/src/verify.cc
index b49695c7..c42a10d4 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -1780,6 +1780,8 @@ dcp::verify (
notes.push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::FAILED_READ, string(e.what())});
} catch (MXFFileError& e) {
notes.push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::FAILED_READ, string(e.what())});
+ } catch (BadURNUUIDError& e) {
+ notes.push_back({VerificationNote::Type::ERROR, VerificationNote::Code::FAILED_READ, string(e.what())});
} catch (cxml::Error& e) {
notes.push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::FAILED_READ, string(e.what())});
}
@@ -1859,7 +1861,7 @@ dcp::note_to_string (VerificationNote note)
case VerificationNote::Code::INVALID_XML:
return String::compose("An XML file is badly formed: %1 (%2:%3)", note.note().get(), note.file()->filename(), note.line().get());
case VerificationNote::Code::MISSING_ASSETMAP:
- return "No ASSETMAP or ASSETMAP.xml was found.";
+ return "No valid ASSETMAP or ASSETMAP.xml was found.";
case VerificationNote::Code::INVALID_INTRINSIC_DURATION:
return String::compose("The intrinsic duration of the asset %1 is less than 1 second.", note.note().get());
case VerificationNote::Code::INVALID_DURATION: