summaryrefslogtreecommitdiff
path: root/src/verify.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-06-11 16:49:33 +0200
committerCarl Hetherington <cth@carlh.net>2020-06-11 16:49:33 +0200
commita8d652b787b986ec5552816ec24367d98243f6fa (patch)
tree4ae8a60a2a82ff8e5967b62d5869748685915d72 /src/verify.cc
parentc6c18f429487fd2cefc0f1cf2424a8bb6065862b (diff)
Fix failure to verify when the XSD/DTD path has a space in it.
With spaces in the path we ended up with spaces in the string passed to setExternalSchemaLocation which screws everything up. It turns out we can remove the URIs from that string, which seems to move the resolution between file and URI to the LocalFileResolver, which may now be asked to resolve either a file or a URI. Maybe I've missed something obvious here.
Diffstat (limited to 'src/verify.cc')
-rw-r--r--src/verify.cc40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/verify.cc b/src/verify.cc
index 0820c7b0..6daf0707 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -210,11 +210,12 @@ public:
InputSource* resolveEntity(XMLCh const *, XMLCh const * system_id)
{
string system_id_str = xml_ch_to_string (system_id);
+ boost::filesystem::path p = _xsd_dtd_directory;
if (_files.find(system_id_str) == _files.end()) {
- return 0;
+ p /= system_id_str;
+ } else {
+ p /= _files[system_id_str];
}
-
- boost::filesystem::path p = _xsd_dtd_directory / _files[system_id_str];
StringToXMLCh ch (p.string());
return new LocalFileInputSource(ch.get());
}
@@ -264,25 +265,22 @@ validate_xml (T xml, boost::filesystem::path xsd_dtd_directory, list<Verificatio
parser.setDoNamespaces(true);
parser.setDoSchema(true);
- map<string, string> schema;
- schema["http://www.w3.org/2000/09/xmldsig#"] = "xmldsig-core-schema.xsd";
- schema["http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"] = "xmldsig-core-schema.xsd";
- schema["http://www.smpte-ra.org/schemas/429-7/2006/CPL"] = "SMPTE-429-7-2006-CPL.xsd";
- schema["http://www.smpte-ra.org/schemas/429-8/2006/PKL"] = "SMPTE-429-8-2006-PKL.xsd";
- schema["http://www.smpte-ra.org/schemas/429-9/2007/AM"] = "SMPTE-429-9-2007-AM.xsd";
- schema["http://www.digicine.com/schemas/437-Y/2007/Main-Stereo-Picture-CPL.xsd"] = "Main-Stereo-Picture-CPL.xsd";
- schema["http://www.digicine.com/PROTO-ASDCP-CPL-20040511#"] = "PROTO-ASDCP-CPL-20040511.xsd";
- schema["http://www.digicine.com/PROTO-ASDCP-PKL-20040311#"] = "PROTO-ASDCP-PKL-20040311.xsd";
- schema["http://www.digicine.com/PROTO-ASDCP-AM-20040311#"] = "PROTO-ASDCP-AM-20040311.xsd";
- schema["interop-subs"] = "DCSubtitle.v1.mattsson.xsd";
- schema["http://www.smpte-ra.org/schemas/428-7/2010/DCST.xsd"] = "DCDMSubtitle-2010.xsd";
-
+ vector<string> schema;
+ schema.push_back("xmldsig-core-schema.xsd");
+ schema.push_back("SMPTE-429-7-2006-CPL.xsd");
+ schema.push_back("SMPTE-429-8-2006-PKL.xsd");
+ schema.push_back("SMPTE-429-9-2007-AM.xsd");
+ schema.push_back("Main-Stereo-Picture-CPL.xsd");
+ schema.push_back("PROTO-ASDCP-CPL-20040511.xsd");
+ schema.push_back("PROTO-ASDCP-PKL-20040311.xsd");
+ schema.push_back("PROTO-ASDCP-AM-20040311.xsd");
+ schema.push_back("DCSubtitle.v1.mattsson.xsd");
+ schema.push_back("DCDMSubtitle-2010.xsd");
+
+ /* XXX: I'm not especially clear what this is for, but it seems to be necessary */
string locations;
- for (map<string, string>::const_iterator i = schema.begin(); i != schema.end(); ++i) {
- locations += i->first;
- locations += " ";
- boost::filesystem::path p = xsd_dtd_directory / i->second;
- locations += p.string() + " ";
+ BOOST_FOREACH (string i, schema) {
+ locations += String::compose("%1 %1 ", i, i);
}
parser.setExternalSchemaLocation(locations.c_str());