]> granicus.if.org Git - apache/commitdiff
mod_proxy_html: skip documents < 4 bytes
authorNick Kew <niq@apache.org>
Sun, 1 Jun 2014 17:33:16 +0000 (17:33 +0000)
committerNick Kew <niq@apache.org>
Sun, 1 Jun 2014 17:33:16 +0000 (17:33 +0000)
PR 56286
Micha Lenk

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1599012 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/filters/mod_proxy_html.c

diff --git a/CHANGES b/CHANGES
index f49bdf973ee3da0e86eb6ba6ad7b4762e54073ac..e377a6e034aac66b802cc2b6c25f334fb4142a04 100644 (file)
--- 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 <micha lenk info>]
+
   *) mod_proxy_fdpass: Fix computation of the size of 'struct sockaddr_un'
      when passed to 'connec()'.
      [Graham Dumpleton <grahamd apache org>]
index 76fc6b56e9759a6f4a58dff70ab51c6617efebf0..8db7997e360e65a8c151598688456a7463a1f8ba 100644 (file)
@@ -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)) {