]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
merge this fix from 2.1-dev:
authorJeff Trawick <trawick@apache.org>
Wed, 17 Sep 2003 10:39:43 +0000 (10:39 +0000)
committerJeff Trawick <trawick@apache.org>
Wed, 17 Sep 2003 10:39:43 +0000 (10:39 +0000)
    * Fix mod_deflate not to search somewhere in the memory for the "gzip"
      token and to skip token parameters. PR 21523.
      Don't compress if there was *any* non-identity endoding applied before.

PR:               21523
Submitted by:   Joe Orton, Andr�� Malo
Reviewed by:   striker, trawick

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

CHANGES
STATUS
modules/filters/mod_deflate.c

diff --git a/CHANGES b/CHANGES
index 7a9e6c87e0661fe0913b6524c09ea3d708b20210..b5a7e06fdca3101904128beb6c0abb150162e20f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Changes with Apache 2.0.48
 
+  *) Fix a bug, where mod_deflate sometimes unconditionally compressed the
+     content if the Accept-Encoding header contained only other tokens than
+     "gzip" (such as "deflate"). PR 21523.  [Joe Orton, André Malo]
+
   *) Avoid an infinite recursion, which occured if the name of an included
      config file or directory contained a wildcard character. PR 22194.
      [André Malo]
diff --git a/STATUS b/STATUS
index ea7b2435d513a929845a68cbb6f3317b30a7b283..b840e33b03610f3498e3b38721f2b95e4ee7ad21 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 APACHE 2.0 STATUS:                                              -*-text-*-
-Last modified at [$Date: 2003/09/17 10:30:46 $]
+Last modified at [$Date: 2003/09/17 10:39:43 $]
 
 Release:
 
@@ -289,12 +289,6 @@ PATCHES TO PORT FROM 2.1
         modules/mappers/mod_rewrite.c: r1.228
       +1: nd
 
-    * Fix mod_deflate not to search somewhere in the memory for the "gzip"
-      token and to skip token parameters. PR 21523.
-      Don't compress if there was *any* non-identity endoding applied before.
-        modules/filters/mod_deflate.c: r1.37, r1.38
-      +1: nd, striker, trawick, jorton
-
     * Fix mod_log_config's %b format to write "-" in case of bytes_sent == 0.
         modules/loggers/mod_log_config.c: r1.106
       +1: nd, jorton
index 3730b5685b089cf72ac859c19e56a9d9f8243e6d..74d3c039743d66bf712a538f6ea5c1297d4d7e78 100644 (file)
@@ -325,7 +325,8 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
         }
 
         /* Let's see what our current Content-Encoding is.
-         * If gzip is present, don't gzip again.  (We could, but let's not.)
+         * If it's already encoded, don't compress again.
+         * (We could, but let's not.)
          */
         encoding = apr_table_get(r->headers_out, "Content-Encoding");
         if (encoding) {
@@ -350,14 +351,20 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
             const char *tmp = encoding;
 
             token = ap_get_token(r->pool, &tmp, 0);
-            while (token && token[0]) {
-                if (!strcasecmp(token, "gzip")) {
+            while (token && *token) {
+                /* stolen from mod_negotiation: */
+                if (strcmp(token, "identity") && strcmp(token, "7bit") &&
+                    strcmp(token, "8bit") && strcmp(token, "binary")) {
+
                     ap_remove_output_filter(f);
                     return ap_pass_brigade(f->next, bb);                       
                 }
+
                 /* Otherwise, skip token */
-                tmp++;
-                token = ap_get_token(r->pool, &tmp, 0);
+                if (*tmp) {
+                    ++tmp;
+                }
+                token = (*tmp) ? ap_get_token(r->pool, &tmp, 0) : NULL;
             }
         }
 
@@ -376,9 +383,17 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
 
         token = ap_get_token(r->pool, &accepts, 0);
         while (token && token[0] && strcasecmp(token, "gzip")) {
-            /* skip token */
-            accepts++;
-            token = ap_get_token(r->pool, &accepts, 0);
+            /* skip parameters, XXX: ;q=foo evaluation? */
+            while (*accepts == ';') { 
+                ++accepts;
+                token = ap_get_token(r->pool, &accepts, 1);
+            }
+
+            /* retrieve next token */
+            if (*accepts == ',') {
+                ++accepts;
+            }
+            token = (*accepts) ? ap_get_token(r->pool, &accepts, 0) : NULL;
         }
 
         /* No acceptable token found. */