From: Eric Covener Date: Wed, 10 Jan 2018 13:47:53 +0000 (+0000) Subject: avoid ap_set_content_type when processing a _Request_Header set|edit|unset Content... X-Git-Tag: 2.5.0-alpha2-ci-test-only~2985 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62e7bd1c9f46652bdd90041e53d7186192a984c3;p=thirdparty%2Fapache%2Fhttpd.git avoid ap_set_content_type when processing a _Request_Header set|edit|unset Content-Type. identified by ylavic git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1820750 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 70496956377..80f0ab127ed 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,12 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.1 + + *) mod_headers: 'RequestHeader set|edit|edit_r Content-Type X' could + inadvertently modify the Content-Type _response_ header. Applies to + Content-Type only and likely to only affect static file responses. + [Eric Covener] + *) mod_cgi: Improve AH01215 messages to make it more clear that the message is the CGI scripts stderr output. PR 61980. [Hank Ibell ] diff --git a/modules/metadata/mod_headers.c b/modules/metadata/mod_headers.c index 102b3ff794f..616ad7b221a 100644 --- a/modules/metadata/mod_headers.c +++ b/modules/metadata/mod_headers.c @@ -791,14 +791,16 @@ static int do_headers_fixup(request_rec *r, apr_table_t *headers, } break; case hdr_set: - if (!ap_cstr_casecmp(hdr->header, "Content-Type")) { + if (r->headers_in != headers && + !ap_cstr_casecmp(hdr->header, "Content-Type")) { ap_set_content_type(r, process_tags(hdr, r)); } apr_table_setn(headers, hdr->header, process_tags(hdr, r)); break; case hdr_setifempty: if (NULL == apr_table_get(headers, hdr->header)) { - if (!ap_cstr_casecmp(hdr->header, "Content-Type")) { + if (r->headers_in != headers && + !ap_cstr_casecmp(hdr->header, "Content-Type")) { ap_set_content_type(r, process_tags(hdr, r)); } apr_table_setn(headers, hdr->header, process_tags(hdr, r)); @@ -806,7 +808,8 @@ static int do_headers_fixup(request_rec *r, apr_table_t *headers, break; case hdr_unset: apr_table_unset(headers, hdr->header); - if (!ap_cstr_casecmp(hdr->header, "Content-Type")) { + if (r->headers_in != headers && + !ap_cstr_casecmp(hdr->header, "Content-Type")) { ap_set_content_type(r, NULL); } break; @@ -821,7 +824,7 @@ static int do_headers_fixup(request_rec *r, apr_table_t *headers, const char *repl = process_regexp(hdr, r->content_type, r); if (repl == NULL) return 0; - ap_set_content_type(r, repl); + if (r->headers_in != headers) ap_set_content_type(r, repl); } if (apr_table_get(headers, hdr->header)) { edit_do ed;