Skip to content

Commit 032ccae

Browse files
authored
Merge pull request #3455 from airween/v3/xmldeprfix
fix: libxml2 related deprecated issues in v3
2 parents 3d0440e + b9dc9cc commit 032ccae

File tree

6 files changed

+5
-24
lines changed

6 files changed

+5
-24
lines changed

src/operators/validate_dtd.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ bool ValidateDTD::init(const std::string &file, std::string *error) {
3333
return false;
3434
}
3535

36-
xmlThrDefSetGenericErrorFunc(NULL,
37-
null_error);
38-
39-
xmlSetGenericErrorFunc(NULL,
40-
null_error);
41-
4236
return true;
4337
}
4438

src/operators/validate_dtd.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ class ValidateDTD : public Operator {
7878
}
7979

8080

81-
static void null_error(void *, const char *, ...) { // cppcheck-suppress[constParameterPointer,constParameterCallback]
82-
}
83-
8481
private:
8582
std::string m_resource;
8683
#endif

src/operators/validate_schema.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ bool ValidateSchema::evaluate(Transaction *transaction,
7171
(xmlSchemaValidityErrorFunc)error_load,
7272
(xmlSchemaValidityWarningFunc)warn_load, &m_err);
7373

74-
xmlThrDefSetGenericErrorFunc(parserCtx,
75-
null_error);
76-
77-
xmlSetGenericErrorFunc(parserCtx,
78-
null_error);
79-
8074
xmlSchemaPtr schema = xmlSchemaParse(parserCtx);
8175
if (schema == NULL) {
8276
std::stringstream err;

src/operators/validate_schema.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ class ValidateSchema : public Operator {
7575
va_end(args);
7676
}
7777

78-
static void null_error(void *, const char *, ...) { // cppcheck-suppress[constParameterPointer,constParameterCallback]
79-
}
8078

8179
template<typename Pred>
8280
static void callback_func(void *ctx, Pred pred, const char *base_msg, const char *msg, va_list args) {

src/request_body_processor/xml.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ bool XML::processChunk(const char *buf, unsigned int size,
249249
error->assign("XML: Failed to create parsing context.");
250250
return false;
251251
}
252+
// disable parser errors being printed to stderr
253+
m_data.parsing_ctx->options |= XML_PARSE_NOWARNING | XML_PARSE_NOERROR;
252254
}
253255

254256
if (m_transaction->m_secXMLParseXmlIntoArgs
@@ -265,6 +267,8 @@ bool XML::processChunk(const char *buf, unsigned int size,
265267
error->assign("XML: Failed to create parsing context for ARGS.");
266268
return false;
267269
}
270+
// disable parser errors being printed to stderr
271+
m_data.parsing_ctx_arg->options |= XML_PARSE_NOWARNING | XML_PARSE_NOERROR;
268272
}
269273

270274
return true;
@@ -274,7 +278,6 @@ bool XML::processChunk(const char *buf, unsigned int size,
274278
if (m_data.parsing_ctx != NULL &&
275279
m_transaction->m_secXMLParseXmlIntoArgs
276280
!= RulesSetProperties::OnlyArgsConfigXMLParseXmlIntoArgs) {
277-
xmlSetGenericErrorFunc(m_data.parsing_ctx, null_error);
278281
xmlParseChunk(m_data.parsing_ctx, buf, size, 0);
279282
m_data.xml_parser_state->parsing_ctx_arg = m_data.parsing_ctx_arg;
280283
if (m_data.parsing_ctx->wellFormed != 1) {
@@ -292,7 +295,6 @@ bool XML::processChunk(const char *buf, unsigned int size,
292295
m_transaction->m_secXMLParseXmlIntoArgs
293296
== RulesSetProperties::TrueConfigXMLParseXmlIntoArgs)
294297
) {
295-
xmlSetGenericErrorFunc(m_data.parsing_ctx_arg, null_error);
296298
xmlParseChunk(m_data.parsing_ctx_arg, buf, size, 0);
297299
if (m_data.parsing_ctx_arg->wellFormed != 1) {
298300
error->assign("XML: Failed to parse document for ARGS.");

src/request_body_processor/xml.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifdef WITH_LIBXML2
1717
#include <libxml/xmlschemas.h>
1818
#include <libxml/xpath.h>
19-
#include <libxml/SAX.h>
19+
#include <libxml/SAX2.h>
2020
#endif
2121

2222
#include <string>
@@ -93,10 +93,6 @@ class XML {
9393
static xmlParserInputBufferPtr unloadExternalEntity(const char *URI,
9494
xmlCharEncoding enc);
9595

96-
static void null_error(void *ctx, const char *msg, ...) { // cppcheck-suppress[constParameterPointer,constParameterCallback]
97-
}
98-
99-
10096
xml_data m_data;
10197

10298
private:

0 commit comments

Comments
 (0)