From 1a1ad378a86e4546c746ac5b89377f50d8580c15 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 8 May 2020 22:44:50 +0200 Subject: Store and allow access to the raw XML that is read in from subtitle assets so that it cab be verified without any interference from being passed through libdcp. --- src/interop_subtitle_asset.cc | 2 ++ src/smpte_subtitle_asset.cc | 11 +++++------ src/subtitle_asset.h | 7 +++++++ 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/interop_subtitle_asset.cc b/src/interop_subtitle_asset.cc index d250b752..39521ed7 100644 --- a/src/interop_subtitle_asset.cc +++ b/src/interop_subtitle_asset.cc @@ -61,6 +61,8 @@ using namespace dcp; InteropSubtitleAsset::InteropSubtitleAsset (boost::filesystem::path file) : SubtitleAsset (file) { + _raw_xml = dcp::file_to_string (file); + shared_ptr xml (new cxml::Document ("DCSubtitle")); xml->read_file (file); _id = xml->string_child ("SubtitleID"); diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index 33a0c943..81a0aa6f 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -94,15 +94,15 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file) _id = read_writer_info (info); if (!_key_id) { /* Not encrypted; read it in now */ - string s; - reader->ReadTimedTextResource (s); - xml->read_string (s); + reader->ReadTimedTextResource (_raw_xml); + xml->read_string (_raw_xml); parse_xml (xml); read_mxf_descriptor (reader, shared_ptr (new DecryptionContext (optional(), SMPTE))); } } else { /* Plain XML */ try { + _raw_xml = dcp::file_to_string (file); xml.reset (new cxml::Document ("SubtitleReel")); xml->read_file (file); parse_xml (xml); @@ -278,11 +278,10 @@ SMPTESubtitleAsset::set_key (Key key) ); } - string s; shared_ptr dec (new DecryptionContext (key, SMPTE)); - reader->ReadTimedTextResource (s, dec->context(), dec->hmac()); + reader->ReadTimedTextResource (_raw_xml, dec->context(), dec->hmac()); shared_ptr xml (new cxml::Document ("SubtitleReel")); - xml->read_string (s); + xml->read_string (_raw_xml); parse_xml (xml); read_mxf_descriptor (reader, dec); } diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h index 9792ce05..fd233cc8 100644 --- a/src/subtitle_asset.h +++ b/src/subtitle_asset.h @@ -105,6 +105,10 @@ public: virtual std::list > load_font_nodes () const = 0; + std::string raw_xml () const { + return _raw_xml; + } + protected: friend struct ::interop_dcp_font_test; friend struct ::smpte_dcp_font_test; @@ -174,6 +178,9 @@ protected: /** TTF font data that we need */ std::list _fonts; + /** The raw XML data that we read from our asset; useful for validation */ + std::string _raw_xml; + private: friend struct ::pull_fonts_test1; friend struct ::pull_fonts_test2; -- cgit v1.2.3