]> granicus.if.org Git - php/commitdiff
Update header handling to RFC 7230
authorStanislav Malyshev <stas@php.net>
Wed, 4 Feb 2015 09:11:00 +0000 (01:11 -0800)
committerStanislav Malyshev <stas@php.net>
Fri, 6 Feb 2015 04:10:28 +0000 (20:10 -0800)
ext/standard/tests/general_functions/bug60227_2.phpt
ext/standard/tests/general_functions/bug60227_3.phpt
ext/standard/tests/general_functions/bug60227_4.phpt
main/SAPI.c

index 995c364eea23fa5ea5960ea1d19a2403b23eb819..2cdde78a4a9140d98acf0e5683aaaaaf6213e063 100644 (file)
@@ -1,14 +1,15 @@
 --TEST--
 Bug #60227 (header() cannot detect the multi-line header with CR), \r before \n
+--INI--
+expose_php=0
 --FILE--
 <?php
 header("X-foo: e\n foo");
-header("X-Foo6: e\rSet-Cookie: ID=123\n d");
 echo 'foo';
 ?>
 --EXPECTF--
+
 Warning: Header may not contain more than a single header, new line detected in %s on line %d
 foo
 --EXPECTHEADERS--
-X-foo: e
-foo
+Content-type: text/html; charset=UTF-8
index 8cba9b8aec67eba90a6e3aabfa2002cd107ce580..8246f1743835c307beb889604bc1f3ba76d0fb4a 100644 (file)
@@ -1,8 +1,9 @@
 --TEST--
 Bug #60227 (header() cannot detect the multi-line header with CR), \0 before \n
+--INI--
+expose_php=0
 --FILE--
 <?php
-header("X-foo: e\n foo");
 header("X-Foo6: e\0Set-Cookie: ID=\n123\n d");
 echo 'foo';
 ?>
@@ -10,5 +11,4 @@ echo 'foo';
 Warning: Header may not contain NUL bytes in %s on line %d
 foo
 --EXPECTHEADERS--
-X-foo: e
-foo
+Content-type: text/html; charset=UTF-8
index d5e2573d89cdc1420553dc7de89806f3f0ae85e0..20dba1a26568e55ad47a0af4e91efe9f59a417ba 100644 (file)
@@ -1,8 +1,9 @@
 --TEST--
 Bug #60227 (header() cannot detect the multi-line header with CR), CRLF
+--INI--
+expose_php=0
 --FILE--
 <?php
-header("X-foo: e\r\n foo");
 header("X-foo: e\r\nfoo");
 echo 'foo';
 ?>
@@ -10,5 +11,4 @@ echo 'foo';
 Warning: Header may not contain more than a single header, new line detected in %s on line %d
 foo
 --EXPECTHEADERS--
-X-foo: e
- foo
+Content-type: text/html; charset=UTF-8
index 0106448b7ac8ef584a68a47524d6f7c463a24efd..6a4105970a8c47087b47ea56181c9993f65a4bb1 100644 (file)
@@ -744,13 +744,8 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
                /* new line/NUL character safety check */
                uint i;
                for (i = 0; i < header_line_len; i++) {
-                       /* RFC 2616 allows new lines if followed by SP or HT */
-                       int illegal_break =
-                                       (header_line[i+1] != ' ' && header_line[i+1] != '\t')
-                                       && (
-                                               header_line[i] == '\n'
-                                               || (header_line[i] == '\r' && header_line[i+1] != '\n'));
-                       if (illegal_break) {
+                       /* RFC 7230 ch. 3.2.4 deprecates folding support */
+                       if (header_line[i] == '\n' || header_line[i] == '\r') {
                                efree(header_line);
                                sapi_module.sapi_error(E_WARNING, "Header may not contain "
                                                "more than a single header, new line detected");