From: Nick Kew Date: Mon, 6 Mar 2017 23:00:36 +0000 (+0000) Subject: mod_xml2enc: cut out inappropriate fallback (and misleading log message) X-Git-Tag: 2.5.0-alpha~582 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c57a036dc3e116f5a397bd6a97da77dd6b503a83;p=thirdparty%2Fapache%2Fhttpd.git mod_xml2enc: cut out inappropriate fallback (and misleading log message) when we've failed to detect a charset but successfully fallen back to config default. Analysis by Tim Skopnik, patch by niq. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1785780 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/filters/mod_xml2enc.c b/modules/filters/mod_xml2enc.c index 7b34c717af9..72d3741c00e 100644 --- a/modules/filters/mod_xml2enc.c +++ b/modules/filters/mod_xml2enc.c @@ -245,7 +245,13 @@ static void sniff_encoding(request_rec* r, xml2ctx* ctx) cfg = ap_get_module_config(r->per_dir_config, &xml2enc_module); if (!ctx->encoding) { ctx->encoding = cfg->default_charset?cfg->default_charset:"ISO-8859-1"; + ctx->xml2enc = xmlParseCharEncoding(ctx->encoding); } + } + /* Test again: this fallback is only appropriate if we couldn't + * just fall back to the configuration default. + */ + if (!HAVE_ENCODING(ctx->xml2enc)) { /* Unsupported charset. Can we get (iconv) support through apr_xlate? */ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01434) "Charset %s not supported by libxml2; trying apr_xlate",