From: Nick Kew Date: Sun, 1 Jun 2014 17:33:16 +0000 (+0000) Subject: mod_proxy_html: skip documents < 4 bytes X-Git-Tag: 2.5.0-alpha~4126 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0cf707e4c3a461ed5334eba7c984f7e36f0270a;p=apache mod_proxy_html: skip documents < 4 bytes PR 56286 Micha Lenk git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1599012 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index f49bdf973e..e377a6e034 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_proxy_html: skip documents shorter than 4 bytes + PR 56286 [Micha Lenk ] + *) mod_proxy_fdpass: Fix computation of the size of 'struct sockaddr_un' when passed to 'connec()'. [Graham Dumpleton ] diff --git a/modules/filters/mod_proxy_html.c b/modules/filters/mod_proxy_html.c index 76fc6b56e9..8db7997e36 100644 --- a/modules/filters/mod_proxy_html.c +++ b/modules/filters/mod_proxy_html.c @@ -889,6 +889,15 @@ static apr_status_t proxy_html_filter(ap_filter_t *f, apr_bucket_brigade *bb) else if (apr_bucket_read(b, &buf, &bytes, APR_BLOCK_READ) == APR_SUCCESS) { if (ctxt->parser == NULL) { + /* For documents smaller than four bytes, there is no reason to do + * HTML rewriting. The URL schema (i.e. 'http') needs four bytes alone. + * And the HTML parser needs at least four bytes to initialise correctly. + */ + if ((bytes < 4) && APR_BUCKET_IS_EOS(APR_BUCKET_NEXT(b))) { + ap_remove_output_filter(f) ; + return ap_pass_brigade(f->next, bb) ; + } + const char *cenc; if (!xml2enc_charset || (xml2enc_charset(f->r, &enc, &cenc) != APR_SUCCESS)) {