mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-15 17:12:14 +03:00
Merge pull request #3455 from airween/v3/xmldeprfix
fix: libxml2 related deprecated issues in v3
This commit is contained in:
@@ -33,12 +33,6 @@ bool ValidateDTD::init(const std::string &file, std::string *error) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlThrDefSetGenericErrorFunc(NULL,
|
|
||||||
null_error);
|
|
||||||
|
|
||||||
xmlSetGenericErrorFunc(NULL,
|
|
||||||
null_error);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,9 +78,6 @@ class ValidateDTD : public Operator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void null_error(void *, const char *, ...) { // cppcheck-suppress[constParameterPointer,constParameterCallback]
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_resource;
|
std::string m_resource;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -71,12 +71,6 @@ bool ValidateSchema::evaluate(Transaction *transaction,
|
|||||||
(xmlSchemaValidityErrorFunc)error_load,
|
(xmlSchemaValidityErrorFunc)error_load,
|
||||||
(xmlSchemaValidityWarningFunc)warn_load, &m_err);
|
(xmlSchemaValidityWarningFunc)warn_load, &m_err);
|
||||||
|
|
||||||
xmlThrDefSetGenericErrorFunc(parserCtx,
|
|
||||||
null_error);
|
|
||||||
|
|
||||||
xmlSetGenericErrorFunc(parserCtx,
|
|
||||||
null_error);
|
|
||||||
|
|
||||||
xmlSchemaPtr schema = xmlSchemaParse(parserCtx);
|
xmlSchemaPtr schema = xmlSchemaParse(parserCtx);
|
||||||
if (schema == NULL) {
|
if (schema == NULL) {
|
||||||
std::stringstream err;
|
std::stringstream err;
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ class ValidateSchema : public Operator {
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void null_error(void *, const char *, ...) { // cppcheck-suppress[constParameterPointer,constParameterCallback]
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Pred>
|
template<typename Pred>
|
||||||
static void callback_func(void *ctx, Pred pred, const char *base_msg, const char *msg, va_list args) {
|
static void callback_func(void *ctx, Pred pred, const char *base_msg, const char *msg, va_list args) {
|
||||||
|
|||||||
@@ -249,6 +249,8 @@ bool XML::processChunk(const char *buf, unsigned int size,
|
|||||||
error->assign("XML: Failed to create parsing context.");
|
error->assign("XML: Failed to create parsing context.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// disable parser errors being printed to stderr
|
||||||
|
m_data.parsing_ctx->options |= XML_PARSE_NOWARNING | XML_PARSE_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_transaction->m_secXMLParseXmlIntoArgs
|
if (m_transaction->m_secXMLParseXmlIntoArgs
|
||||||
@@ -265,6 +267,8 @@ bool XML::processChunk(const char *buf, unsigned int size,
|
|||||||
error->assign("XML: Failed to create parsing context for ARGS.");
|
error->assign("XML: Failed to create parsing context for ARGS.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// disable parser errors being printed to stderr
|
||||||
|
m_data.parsing_ctx_arg->options |= XML_PARSE_NOWARNING | XML_PARSE_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -274,7 +278,6 @@ bool XML::processChunk(const char *buf, unsigned int size,
|
|||||||
if (m_data.parsing_ctx != NULL &&
|
if (m_data.parsing_ctx != NULL &&
|
||||||
m_transaction->m_secXMLParseXmlIntoArgs
|
m_transaction->m_secXMLParseXmlIntoArgs
|
||||||
!= RulesSetProperties::OnlyArgsConfigXMLParseXmlIntoArgs) {
|
!= RulesSetProperties::OnlyArgsConfigXMLParseXmlIntoArgs) {
|
||||||
xmlSetGenericErrorFunc(m_data.parsing_ctx, null_error);
|
|
||||||
xmlParseChunk(m_data.parsing_ctx, buf, size, 0);
|
xmlParseChunk(m_data.parsing_ctx, buf, size, 0);
|
||||||
m_data.xml_parser_state->parsing_ctx_arg = m_data.parsing_ctx_arg;
|
m_data.xml_parser_state->parsing_ctx_arg = m_data.parsing_ctx_arg;
|
||||||
if (m_data.parsing_ctx->wellFormed != 1) {
|
if (m_data.parsing_ctx->wellFormed != 1) {
|
||||||
@@ -292,7 +295,6 @@ bool XML::processChunk(const char *buf, unsigned int size,
|
|||||||
m_transaction->m_secXMLParseXmlIntoArgs
|
m_transaction->m_secXMLParseXmlIntoArgs
|
||||||
== RulesSetProperties::TrueConfigXMLParseXmlIntoArgs)
|
== RulesSetProperties::TrueConfigXMLParseXmlIntoArgs)
|
||||||
) {
|
) {
|
||||||
xmlSetGenericErrorFunc(m_data.parsing_ctx_arg, null_error);
|
|
||||||
xmlParseChunk(m_data.parsing_ctx_arg, buf, size, 0);
|
xmlParseChunk(m_data.parsing_ctx_arg, buf, size, 0);
|
||||||
if (m_data.parsing_ctx_arg->wellFormed != 1) {
|
if (m_data.parsing_ctx_arg->wellFormed != 1) {
|
||||||
error->assign("XML: Failed to parse document for ARGS.");
|
error->assign("XML: Failed to parse document for ARGS.");
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#ifdef WITH_LIBXML2
|
#ifdef WITH_LIBXML2
|
||||||
#include <libxml/xmlschemas.h>
|
#include <libxml/xmlschemas.h>
|
||||||
#include <libxml/xpath.h>
|
#include <libxml/xpath.h>
|
||||||
#include <libxml/SAX.h>
|
#include <libxml/SAX2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -93,10 +93,6 @@ class XML {
|
|||||||
static xmlParserInputBufferPtr unloadExternalEntity(const char *URI,
|
static xmlParserInputBufferPtr unloadExternalEntity(const char *URI,
|
||||||
xmlCharEncoding enc);
|
xmlCharEncoding enc);
|
||||||
|
|
||||||
static void null_error(void *ctx, const char *msg, ...) { // cppcheck-suppress[constParameterPointer,constParameterCallback]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
xml_data m_data;
|
xml_data m_data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user