Adds support to SecXMLExternalEntity

This commit is contained in:
Felipe Zimmerle
2016-05-18 17:01:53 -03:00
parent 6a7b970fe3
commit f989ecd5cb
13 changed files with 215 additions and 30 deletions

View File

@@ -39,14 +39,6 @@ bool ValidateDTD::init(const std::string &file, const char **error) {
xmlSetGenericErrorFunc(NULL,
null_error);
m_dtd = xmlParseDTD(NULL, (const xmlChar *)m_resource.c_str());
if (m_dtd == NULL) {
std::string err = std::string("XML: Failed to load DTD: ") \
+ m_resource;
*error = strdup(err.c_str());
return false;
}
return true;
}
@@ -54,6 +46,14 @@ bool ValidateDTD::init(const std::string &file, const char **error) {
bool ValidateDTD::evaluate(Transaction *t, const std::string &str) {
xmlValidCtxtPtr cvp;
m_dtd = xmlParseDTD(NULL, (const xmlChar *)m_resource.c_str());
if (m_dtd == NULL) {
std::string err = std::string("XML: Failed to load DTD: ") \
+ m_resource;
t->debug(4, err);
return true;
}
if (t->m_xml->m_data.doc == NULL) {
t->debug(4, "XML document tree could not "\
"be found for DTD validation.");

View File

@@ -33,6 +33,14 @@ bool ValidateSchema::init(const std::string &file, const char **error) {
return false;
}
return true;
}
bool ValidateSchema::evaluate(Transaction *t,
const std::string &str) {
int rc;
m_parserCtx = xmlSchemaNewParserCtxt(m_resource.c_str());
if (m_parserCtx == NULL) {
std::stringstream err;
@@ -42,8 +50,8 @@ bool ValidateSchema::init(const std::string &file, const char **error) {
if (m_err.empty() == false) {
err << m_err;
}
*error = strdup(err.str().c_str());
return false;
t->debug(4, err.str());
return true;
}
xmlSchemaSetParserErrors(m_parserCtx,
@@ -65,9 +73,9 @@ bool ValidateSchema::init(const std::string &file, const char **error) {
if (m_err.empty() == false) {
err << " " << m_err;
}
*error = strdup(err.str().c_str());
t->debug(4, err.str());
xmlSchemaFreeParserCtxt(m_parserCtx);
return false;
return true;
}
m_validCtx = xmlSchemaNewValidCtxt(m_schema);
@@ -76,18 +84,10 @@ bool ValidateSchema::init(const std::string &file, const char **error) {
if (m_err.empty() == false) {
err << " " << m_err;
}
*error = strdup(err.str().c_str());
return false;
t->debug(4, err.str());
return true;
}
return true;
}
bool ValidateSchema::evaluate(Transaction *t,
const std::string &str) {
int rc;
/* Send validator errors/warnings to msr_log */
xmlSchemaSetValidErrors(m_validCtx,
(xmlSchemaValidityErrorFunc)error_runtime,