Skip to content

Commit 063621c

Browse files
authored
Merge pull request #3454 from airween/v2/xmldeprfix
Fix libxml2 related deprecated issues
2 parents 6939a21 + 0f62dd9 commit 063621c

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

apache2/msc_crypt.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,26 +1091,34 @@ int inject_hashed_response_body(modsec_rec *msr, int elts) {
10911091
msr_log(msr, 4, "inject_hashed_response_body: Detected encoding type [%s].",
10921092
encoding ? encoding : "(none)");
10931093

1094-
if (handler == NULL)
1094+
if (handler == NULL) {
10951095
handler = xmlFindCharEncodingHandler("UTF-8");
1096-
if (handler == NULL)
1096+
encoding = apr_pstrdup(msr->mp, "UTF-8");
1097+
}
1098+
if (handler == NULL) {
10971099
handler = xmlFindCharEncodingHandler("ISO-8859-1");
1098-
if (handler == NULL)
1100+
encoding = apr_pstrdup(msr->mp, "ISO-8859-1");
1101+
}
1102+
if (handler == NULL) {
10991103
handler = xmlFindCharEncodingHandler("HTML");
1100-
if (handler == NULL)
1104+
encoding = apr_pstrdup(msr->mp, "HTML");
1105+
}
1106+
if (handler == NULL) {
11011107
handler = xmlFindCharEncodingHandler("ascii");
1108+
encoding = apr_pstrdup(msr->mp, "ascii");
1109+
}
11021110

11031111
if(handler == NULL) {
11041112
xmlFreeDoc(msr->crypto_html_tree);
11051113
return -1;
11061114
}
11071115

11081116
apr_table_unset(msr->r->headers_out,"Content-Type");
1109-
new_ct = (char*)apr_psprintf(msr->mp, "text/html;%s",handler->name);
1117+
new_ct = (char*)apr_psprintf(msr->mp, "text/html;%s",encoding);
11101118
apr_table_set(msr->r->err_headers_out,"Content-Type",new_ct);
11111119

11121120
if (msr->txcfg->debuglog_level >= 4)
1113-
msr_log(msr, 4, "inject_hashed_response_body: Using content-type [%s].", handler->name);
1121+
msr_log(msr, 4, "inject_hashed_response_body: Using content-type [%s].", encoding);
11141122

11151123
output_buf = xmlAllocOutputBuffer(handler);
11161124
if (output_buf == NULL) {

apache2/msc_xml.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ typedef struct xml_data xml_data;
2020
#include "modsecurity.h"
2121
#include <libxml/xmlschemas.h>
2222
#include <libxml/xpath.h>
23-
#include <libxml/SAX.h>
23+
#include <libxml/SAX2.h>
2424

2525
/* Structures */
2626

0 commit comments

Comments
 (0)