summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-04-07 20:59:44 +0200
committerCarl Hetherington <cth@carlh.net>2023-04-19 13:00:22 +0200
commit31c09e22b74e3a4cf5c16952f8634caea3920625 (patch)
tree9029b8c7701bea38566a8cd1a0cf79cc215eaf72 /src
parentf73b714742b7233f4cb0d4a497fc610882b0fe00 (diff)
Add test for too many subtitle namespaces.
Diffstat (limited to 'src')
-rw-r--r--src/verify.cc20
-rw-r--r--src/verify.h4
2 files changed, 24 insertions, 0 deletions
diff --git a/src/verify.cc b/src/verify.cc
index 81ca0bc9..6a1cbd2d 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -58,6 +58,7 @@
#include "stereo_picture_frame.h"
#include "verify.h"
#include "verify_j2k.h"
+#include <libxml/parserInternals.h>
#include <xercesc/dom/DOMAttr.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMError.hpp>
@@ -786,15 +787,32 @@ verify_subtitle_asset (
notes.push_back ({VerificationNote::Type::WARNING, VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED});
}
+ auto namespace_count = [](shared_ptr<const SubtitleAsset> asset, string root_node) {
+ cxml::Document doc(root_node);
+ doc.read_string(asset->raw_xml().get());
+ auto root = dynamic_cast<xmlpp::Element*>(doc.node())->cobj();
+ int count = 0;
+ for (auto ns = root->nsDef; ns != nullptr; ns = ns->next) {
+ ++count;
+ }
+ return count;
+ };
+
auto interop = dynamic_pointer_cast<const InteropSubtitleAsset>(asset);
if (interop) {
verify_interop_subtitle_asset(interop, notes);
+ if (namespace_count(asset, "DCSubtitle") > 1) {
+ notes.push_back({ VerificationNote::Type::WARNING, VerificationNote::Code::INCORRECT_SUBTITLE_NAMESPACE_COUNT, asset->id() });
+ }
}
auto smpte = dynamic_pointer_cast<const SMPTESubtitleAsset>(asset);
if (smpte) {
verify_smpte_timed_text_asset (smpte, reel_asset_duration, notes);
verify_smpte_subtitle_asset (smpte, notes, state);
+ if (namespace_count(asset, "SubtitleReel") > 1) {
+ notes.push_back({ VerificationNote::Type::WARNING, VerificationNote::Code::INCORRECT_SUBTITLE_NAMESPACE_COUNT, asset->id()});
+ }
}
}
@@ -2019,6 +2037,8 @@ dcp::note_to_string (VerificationNote note)
"Frame %1 has an image component that is too large (component %2 is %3 bytes in size).",
note.frame().get(), note.component().get(), note.size().get()
);
+ case VerificationNote::Code::INCORRECT_SUBTITLE_NAMESPACE_COUNT:
+ return String::compose("The XML in the subtitle asset %1 has more than one namespace declaration.", note.note().get());
}
return "";
diff --git a/src/verify.h b/src/verify.h
index 69a10292..48c06577 100644
--- a/src/verify.h
+++ b/src/verify.h
@@ -444,6 +444,10 @@ public:
* size contains the invalid size in bytes.
*/
INVALID_JPEG2000_TILE_PART_SIZE,
+ /** A subtitle XML root node has more than one namespace (xmlns) declaration.
+ * note contains the asset ID
+ */
+ INCORRECT_SUBTITLE_NAMESPACE_COUNT
};
VerificationNote (Type type, Code code)