From: Jeff Trawick Date: Wed, 17 Sep 2003 10:39:43 +0000 (+0000) Subject: merge this fix from 2.1-dev: X-Git-Tag: 2.0.48~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21b0c6997be531b7072237bc2d36a7873023bab0;p=thirdparty%2Fapache%2Fhttpd.git merge this fix from 2.1-dev: * 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 --- diff --git a/CHANGES b/CHANGES index 7a9e6c87e06..b5a7e06fdca 100644 --- 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 ea7b2435d51..b840e33b036 100644 --- 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 diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index 3730b5685b0..74d3c039743 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -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. */