Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/KM_xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,15 @@ Kumu::XMLElement::ParseString(const char* document, ui32_t doc_len)
return errorCount > 0 ? false : true;
}


class IgnoreDTDResolver : public xercesc::EntityResolver {
public:
InputSource* resolveEntity(const XMLCh* const, const XMLCh* const) override {
static const XMLByte dummy[] = "";
return new xercesc::MemBufInputSource(dummy, 0, "dummy-dtd", false);
}
};

//
bool
Kumu::XMLElement::ParseFirstFromString(const char* document, ui32_t doc_len)
Expand All @@ -1002,14 +1011,18 @@ Kumu::XMLElement::ParseFirstFromString(const char* document, ui32_t doc_len)
int errorCount = 0;
SAXParser* parser = new SAXParser();

parser->setValidationScheme(SAXParser::Val_Always);
parser->setValidationScheme(SAXParser::Val_Never);
parser->setDoNamespaces(true); // optional

MyTreeHandler* docHandler = new MyTreeHandler(this);
parser->setDocumentHandler(docHandler);
parser->setErrorHandler(docHandler);
XMLPScanToken token;

// Ignore references to DTD files
IgnoreDTDResolver resolver;
parser->setEntityResolver(&resolver);

try
{
MemBufInputSource xmlSource(reinterpret_cast<const XMLByte*>(document),
Expand Down