Skip to content

Commit 6764774

Browse files
committed
avoid ap_set_content_type when processing a _Request_Header set|edit|unset Content-Type.
identified by ylavic Merges r1820750 from trunk Submitted by: covener Reviewed by: covener, rpluem, jorton git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1926323 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1a66f7d commit 6764774

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
-*- coding: utf-8 -*-
22
Changes with Apache 2.4.64
33

4+
*) mod_headers: 'RequestHeader set|edit|edit_r Content-Type X' could
5+
inadvertently modify the Content-Type _response_ header. Applies to
6+
Content-Type only and likely to only affect static file responses.
7+
[Eric Covener]
8+
49
*) mod_ssl: Remove warning over potential uninitialised value
510
for ssl protocol prior to protocol selection.
611
[Graham Leggett]

modules/metadata/mod_headers.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,21 +782,27 @@ static int do_headers_fixup(request_rec *r, apr_table_t *headers,
782782
}
783783
break;
784784
case hdr_set:
785-
if (!ap_cstr_casecmp(hdr->header, "Content-Type")) {
785+
if (r->headers_in != headers &&
786+
!ap_cstr_casecmp(hdr->header, "Content-Type")) {
786787
ap_set_content_type_ex(r, process_tags(hdr, r), 1);
787788
}
788789
apr_table_setn(headers, hdr->header, process_tags(hdr, r));
789790
break;
790791
case hdr_setifempty:
791792
if (NULL == apr_table_get(headers, hdr->header)) {
792-
if (!ap_cstr_casecmp(hdr->header, "Content-Type")) {
793+
if (r->headers_in != headers &&
794+
!ap_cstr_casecmp(hdr->header, "Content-Type")) {
793795
ap_set_content_type_ex(r, process_tags(hdr, r), 1);
794796
}
795797
apr_table_setn(headers, hdr->header, process_tags(hdr, r));
796798
}
797799
break;
798800
case hdr_unset:
799801
apr_table_unset(headers, hdr->header);
802+
if (r->headers_in != headers &&
803+
!ap_cstr_casecmp(hdr->header, "Content-Type")) {
804+
ap_set_content_type(r, NULL);
805+
}
800806
break;
801807
case hdr_echo:
802808
v.r = r;
@@ -809,7 +815,7 @@ static int do_headers_fixup(request_rec *r, apr_table_t *headers,
809815
const char *repl = process_regexp(hdr, r->content_type, r);
810816
if (repl == NULL)
811817
return 0;
812-
ap_set_content_type_ex(r, repl, 1);
818+
if (r->headers_in != headers) ap_set_content_type_ex(r, repl, 1);
813819
}
814820
if (apr_table_get(headers, hdr->header)) {
815821
edit_do ed;

0 commit comments

Comments
 (0)