com php-src: Update header handling to RFC 7230: NEWS ext/standard/tests/general_functions/bug60227_2 .phpt
ext/standard/tests/general_functions/bug602 27_3.phpt ext/standard/tests/general_functions/bu g60227_4.phpt main/SAPI.c
| From: | Stanislav Malyshev | Date: | Fri, 06 Feb 2015 04:08:12 +0000 |
| Subject: | com php-src: Update header handling to RFC 7230: NEWS ext/standard/tests/general_functions/bug60227_2 .phpt ext/standard/tests/general_functions/bug602 27_3.phpt ext/standard/tests/general_functions/bu g60227_4.phpt main/SAPI.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84670@lists.php.net to get a copy of this message | ||
Commit: f001c630732a817fae3a3797643fec76cb4be095
Author: Stanislav Malyshev <stas@php.net> Wed, 4 Feb 2015 01:11:00 -0800
Parents: 7efbd70b034890df171cc0c48363f99121f0c19e
Branches: PHP-5.4 PHP-5.5 PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f001c630732a817fae3a3797643fec76cb4be095
Log:
Update header handling to RFC 7230
Changed paths:
M NEWS
M ext/standard/tests/general_functions/bug60227_2.phpt
M ext/standard/tests/general_functions/bug60227_3.phpt
M ext/standard/tests/general_functions/bug60227_4.phpt
M main/SAPI.c
Diff:
diff --git a/NEWS b/NEWS
index 2e45ad8..462d6a1 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP NEWS
?? ??? 20?? PHP 5.4.38
- Core:
+ . Removed support for multi-line headers, as the are deprecated by RFC 7230.
+ (Stas)
. Fixed bug #68925 (Mitigation for CVE-2015-0235 – GHOST: glibc gethostbyname
buffer overflow). (Stas)
diff --git a/ext/standard/tests/general_functions/bug60227_2.phpt
b/ext/standard/tests/general_functions/bug60227_2..phpt
index 995c364..2cdde78 100644
--- a/ext/standard/tests/general_functions/bug60227_2.phpt
+++ b/ext/standard/tests/general_functions/bug60227_2.phpt
@@ -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
diff --git a/ext/standard/tests/general_functions/bug60227_3.phpt
b/ext/standard/tests/general_functions/bug60227_3..phpt
index 8cba9b8..8246f17 100644
--- a/ext/standard/tests/general_functions/bug60227_3.phpt
+++ b/ext/standard/tests/general_functions/bug60227_3.phpt
@@ -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
diff --git a/ext/standard/tests/general_functions/bug60227_4.phpt
b/ext/standard/tests/general_functions/bug60227_4.phpt
index d5e2573..20dba1a 100644
--- a/ext/standard/tests/general_functions/bug60227_4.phpt
+++ b/ext/standard/tests/general_functions/bug60227_4.phpt
@@ -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
diff --git a/main/SAPI.c b/main/SAPI.c
index 994aff3..1390d29 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -743,13 +743,8 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
/* new line/NUL character safety check */
int 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");