Skip to content

Conversation

@airween
Copy link
Member

@airween airween commented Oct 29, 2025

Similar as #3454 for v2.

what

This PR fixes libxml2 related deprecated warnings.

why

With newest clang and gcc compilers and newest libxml2 library there were a few deprecated warnings.

In file included from ../src/request_body_processor/xml.h:19,
                 from transaction.cc:40:
/usr/include/libxml2/libxml/SAX.h:15:4: warning: #warning "libxml/SAX.h is deprecated" [-Wcpp]
   15 |   #warning "libxml/SAX.h is deprecated"
      |    ^~~~~~~
operators/validate_dtd.cc: In member function 'virtual bool modsecurity::operators::ValidateDTD::init(const std::string&, std::string*)':
operators/validate_dtd.cc:36:33: warning: 'void xmlThrDefSetGenericErrorFunc(void*, xmlGenericErrorFunc)' is deprecated [-Wdeprecated-declarations]
   36 |     xmlThrDefSetGenericErrorFunc(NULL,
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
   37 |         null_error);
      |         ~~~~~~~~~~~              
operators/validate_schema.cc: In member function 'virtual bool modsecurity::operators::ValidateSchema::evaluate(modsecurity::Transaction*, const std::string&)':
operators/validate_schema.cc:74:33: warning: 'void xmlThrDefSetGenericErrorFunc(void*, xmlGenericErrorFunc)' is deprecated [-Wdeprecated-declarations]
   74 |     xmlThrDefSetGenericErrorFunc(parserCtx,
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
   75 |         null_error);
      |         ~~~~~~~~~~~              

I removed not just xmlThrDefSetGenericErrorFunc() call but the xmlSetGenericErrorFunc() too, because in libxml2 documentation both functions are marked as deprecated.

Beside of that, all error handlers are set to a null_error() function which did nothing, so I remove those handlers too, and set the contexts' options to XML_PARSE_NOWARNING | XML_PARSE_NOERROR as libxml2's documentation recommends that.

references

@sonarqubecloud
Copy link

@airween airween requested review from fzipi and theseion October 29, 2025 19:26
@airween airween merged commit 032ccae into owasp-modsecurity:v3/master Oct 30, 2025
50 checks passed
@airween airween added the 3.x Related to ModSecurity version 3.x label Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x Related to ModSecurity version 3.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants