@@ -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 ) {
0 commit comments