From: Nick Kew Date: Sun, 1 Jun 2014 17:33:16 +0000 (+0000) Subject: mod_proxy_html: skip documents < 4 bytes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13ac4f03a16f8f6f383f84d184f252d485b5cbb8;p=thirdparty%2Fapache%2Fhttpd.git 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 f49bdf973ee..e377a6e034a 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 76fc6b56e97..8db7997e360 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)) {