Merge branch 'PHP-5.5' into PHP-5.6

* PHP-5.5:
  Update header handling to RFC 7230
This commit is contained in:
Stanislav Malyshev 2015-02-05 20:09:49 -08:00
commit a1c28567c6
5 changed files with 14 additions and 16 deletions

2
NEWS
View File

@ -7,6 +7,8 @@
?? Feb 2015, PHP 5.6.6 ?? Feb 2015, PHP 5.6.6
- Core: - Core:
. Removed support for multi-line headers, as the are deprecated by RFC 7230.
(Stas)
. Fixed bug #68986 (pointer returned by php_stream_fopen_temporary_file . Fixed bug #68986 (pointer returned by php_stream_fopen_temporary_file
not validated in memory.c). (nayana at ddproperty dot com) not validated in memory.c). (nayana at ddproperty dot com)
. Fixed bug #67068 (getClosure returns somethings that's not a closure). . Fixed bug #67068 (getClosure returns somethings that's not a closure).

View File

@ -1,14 +1,15 @@
--TEST-- --TEST--
Bug #60227 (header() cannot detect the multi-line header with CR), \r before \n Bug #60227 (header() cannot detect the multi-line header with CR), \r before \n
--INI--
expose_php=0
--FILE-- --FILE--
<?php <?php
header("X-foo: e\n foo"); header("X-foo: e\n foo");
header("X-Foo6: e\rSet-Cookie: ID=123\n d");
echo 'foo'; echo 'foo';
?> ?>
--EXPECTF-- --EXPECTF--
Warning: Header may not contain more than a single header, new line detected in %s on line %d Warning: Header may not contain more than a single header, new line detected in %s on line %d
foo foo
--EXPECTHEADERS-- --EXPECTHEADERS--
X-foo: e Content-type: text/html; charset=UTF-8
foo

View File

@ -1,8 +1,9 @@
--TEST-- --TEST--
Bug #60227 (header() cannot detect the multi-line header with CR), \0 before \n Bug #60227 (header() cannot detect the multi-line header with CR), \0 before \n
--INI--
expose_php=0
--FILE-- --FILE--
<?php <?php
header("X-foo: e\n foo");
header("X-Foo6: e\0Set-Cookie: ID=\n123\n d"); header("X-Foo6: e\0Set-Cookie: ID=\n123\n d");
echo 'foo'; echo 'foo';
?> ?>
@ -10,5 +11,4 @@ echo 'foo';
Warning: Header may not contain NUL bytes in %s on line %d Warning: Header may not contain NUL bytes in %s on line %d
foo foo
--EXPECTHEADERS-- --EXPECTHEADERS--
X-foo: e Content-type: text/html; charset=UTF-8
foo

View File

@ -1,8 +1,9 @@
--TEST-- --TEST--
Bug #60227 (header() cannot detect the multi-line header with CR), CRLF Bug #60227 (header() cannot detect the multi-line header with CR), CRLF
--INI--
expose_php=0
--FILE-- --FILE--
<?php <?php
header("X-foo: e\r\n foo");
header("X-foo: e\r\nfoo"); header("X-foo: e\r\nfoo");
echo 'foo'; 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 Warning: Header may not contain more than a single header, new line detected in %s on line %d
foo foo
--EXPECTHEADERS-- --EXPECTHEADERS--
X-foo: e Content-type: text/html; charset=UTF-8
foo

View File

@ -747,13 +747,8 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
/* new line/NUL character safety check */ /* new line/NUL character safety check */
int i; int i;
for (i = 0; i < header_line_len; i++) { for (i = 0; i < header_line_len; i++) {
/* RFC 2616 allows new lines if followed by SP or HT */ /* RFC 7230 ch. 3.2.4 deprecates folding support */
int illegal_break = if (header_line[i] == '\n' || header_line[i] == '\r') {
(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) {
efree(header_line); efree(header_line);
sapi_module.sapi_error(E_WARNING, "Header may not contain " sapi_module.sapi_error(E_WARNING, "Header may not contain "
"more than a single header, new line detected"); "more than a single header, new line detected");