[patch] Apache converts GZIPed data into UTF-8 - 2nd Act

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Oh, nobody has an answer to the issue?

Okay...

Investigating, it appears that mod_xml2enc indeed grabs everything it
can lay hands on, if only it is tagged as some 'text/whatver', and
"converts" it (assuming it were ISO8859-1), no matter the damage, and
giving a f*** damn on compressed data. :((

This gets obvious from the code, it is also visible in the
debuglog:

[proxy_http:trace3] [pid 52505] mod_proxy_http.c(1402): [client 192.168.97.18:28882] Status from backend: 200
[proxy_http:trace4] [pid 52505] mod_proxy_http.c(1052): [client 192.168.97.18:28882] Headers received from backend:
[proxy_http:trace4] [pid 52505] mod_proxy_http.c(1075): [client 192.168.97.18:28882] Last-Modified: Sun, 14 Apr 2019 05:53:26 GMT
[proxy_http:trace4] [pid 52505] mod_proxy_http.c(1075): [client 192.168.97.18:28882] Content-Type: text/css
[proxy_http:trace4] [pid 52505] mod_proxy_http.c(1075): [client 192.168.97.18:28882] Content-Encoding: gzip
[proxy_http:trace4] [pid 52505] mod_proxy_http.c(1075): [client 192.168.97.18:28882] Vary: Accept-Encoding
[proxy_http:trace4] [pid 52505] mod_proxy_http.c(1075): [client 192.168.97.18:28882] Content-Length: 6194
[proxy_http:trace3] [pid 52505] mod_proxy_http.c(1672): [client 192.168.97.18:28882] start body send
[xml2enc:debug] [pid 52505] mod_xml2enc.c(176): [client 192.168.97.18:28882] AH01430: Content-Type is text/css
[xml2enc:debug] [pid 52505] mod_xml2enc.c(250): [client 192.168.97.18:28882] AH01434: Charset ISO-8859-1 not supported by libxml2; trying apr_xlate
[xml2enc:debug] [pid 52505] mod_xml2enc.c(464): [client 192.168.97.18:28882] AH01439: xml2enc: consuming 6194 bytes from bucket
[xml2enc:debug] [pid 52505] mod_xml2enc.c(490): [client 192.168.97.18:28882] AH01441: xml2enc: converted 4049/6193 bytes
[xml2enc:debug] [pid 52505] mod_xml2enc.c(490): [client 192.168.97.18:28882] AH01441: xml2enc: converted 2145/3242 bytes
[proxy_html:trace1] [pid 52505] mod_proxy_html.c(832): [client 192.168.97.18:28882] Non-HTML content; not inserting proxy-html filter
[http:trace3] [pid 52505] http_filters.c(1125): [client 192.168.97.18:28882] Response sent with status 200, headers:
[http:trace5] [pid 52505] http_filters.c(1134): [client 192.168.97.18:28882]   Date: Sun, 14 Apr 2019 16:07:20 GMT
[http:trace5] [pid 52505] http_filters.c(1137): [client 192.168.97.18:28882]   Server: Apache/2.4.39 (FreeBSD)
[http:trace4] [pid 52505] http_filters.c(955): [client 192.168.97.18:28882]   Last-Modified: Sun, 14 Apr 2019 05:53:26 GMT
[http:trace4] [pid 52505] http_filters.c(955): [client 192.168.97.18:28882]   Content-Type: text/css;charset=utf-8
[http:trace4] [pid 52505] http_filters.c(955): [client 192.168.97.18:28882]   Content-Encoding: gzip
[http:trace4] [pid 52505] http_filters.c(955): [client 192.168.97.18:28882]   Vary: Accept-Encoding
[http:trace4] [pid 52505] http_filters.c(955): [client 192.168.97.18:28882]   Keep-Alive: timeout=15, max=100
[http:trace4] [pid 52505] http_filters.c(955): [client 192.168.97.18:28882]   Connection: Keep-Alive
[http:trace4] [pid 52505] http_filters.c(955): [client 192.168.97.18:28882]   Transfer-Encoding: chunked


Then, depending on which filters are configured, this may or may not
happen. It may even be runtime dependent. I tried to put proxy_html
into a filter chain to get a more defined behaviour, but this is not
possible, it produces a configuration error with FilterProvider, 
although the documentation says:
        "Any content filter may be used as a provider to mod_filter;
         no change to existing filter modules is required"
So this does not work, either.

Finally I decided to fix the code, as good as I can. (As stated before, 
I have absolutely no idea about this stuff and it's conventions, I just
need to make the thing workable.)
---------------------------------------------------------------------------
--- modules/filters/mod_xml2enc.c.orig  2018-06-22 10:43:46.000000000 +0000
+++ modules/filters/mod_xml2enc.c       2019-04-14 23:33:16.661705000 +0000
@@ -305,6 +305,7 @@
     apr_size_t insz = 0;
     int pending_meta = 0;
     char *ctype;
+    const char *c_enc = NULL;
     char *p;
 
     if (!ctx || !f->r->content_type) {
@@ -324,6 +325,17 @@
         return ap_pass_brigade(f->next, bb) ;
     }
 
+    if((c_enc = apr_table_get(f->r->headers_out, "Content-Encoding")) &&
+            !strstr(c_enc, "identity") &&
+            !apr_table_get(f->r->notes, "X-PMc-was-here")) {
+        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, APLOGNO(66666)
+             "Probable deflated content, standing down") ;
+        ap_remove_output_filter(f);
+        return ap_pass_brigade(f->next, bb) ;
+    } else {
+        apr_table_set(f->r->notes, "X-PMc-was-here", "1");
+    }
+    
     if (ctx->bbsave == NULL) {
         ctx->bbsave = apr_brigade_create(f->r->pool,
                                          f->r->connection->bucket_alloc);
---------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux