Skip to content

Commit 81db8ec

Browse files
author
hirokawa
committed
fixed bug #60227: header() cannot detect the multi-line header with CR.
git-svn-id: http://svn.php.net/repository/php/php-src/trunk@318820 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent c03a9b6 commit 81db8ec

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #60227 (header() cannot detect the multi-line header with CR)
3+
--FILE--
4+
<?php
5+
header("X-Foo1: a");
6+
header("X-Foo2: b\n ");
7+
header("X-Foo3: c\r\n ");
8+
header("X-Foo4: d\r ");
9+
header("X-Foo5: e\rSet-Cookie: ID=123");
10+
echo 'foo';
11+
?>
12+
--EXPECTF--
13+
Warning: Header may not contain more than a single header, new line detected. in %s on line %d
14+
foo
15+
--EXPECTHEADERS--
16+
X-Foo1: a
17+
X-Foo2: b
18+
X-Foo3: c
19+
X-Foo4: d
20+

main/SAPI.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
712712
} else {
713713
/* new line safety check */
714714
char *s = header_line, *e = header_line + header_line_len, *p;
715-
while (s < e && (p = memchr(s, '\n', (e - s)))) {
715+
while (s < e && ((p = memchr(s, '\n', (e - s))) || (p = memchr(s, '\r', (e - s))))) {
716716
if (*(p + 1) == ' ' || *(p + 1) == '\t') {
717717
s = p + 1;
718718
continue;

0 commit comments

Comments
 (0)