Skip to content

Commit f69bad8

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Don't treat any WS as start of header
2 parents e40b744 + c5128fb commit f69bad8

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

ext/standard/http_fopen_wrapper.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static inline void strip_header(char *header_bag, char *lc_header_bag,
106106
static zend_bool check_has_header(const char *headers, const char *header) {
107107
const char *s = headers;
108108
while ((s = strstr(s, header))) {
109-
if (s == headers || *(s-1) == '\r' || *(s-1) == '\n' || *(s-1) == '\t' || *(s-1) == ' ') {
109+
if (s == headers || *(s-1) == '\n') {
110110
return 1;
111111
}
112112
s++;
@@ -492,8 +492,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
492492

493493
/* remove Proxy-Authorization header */
494494
if (use_proxy && use_ssl && (s = strstr(t, "proxy-authorization:")) &&
495-
(s == t || *(s-1) == '\r' || *(s-1) == '\n' ||
496-
*(s-1) == '\t' || *(s-1) == ' ')) {
495+
(s == t || *(s-1) == '\n')) {
497496
char *p = s + sizeof("proxy-authorization:") - 1;
498497

499498
while (s > t && (*(s-1) == ' ' || *(s-1) == '\t')) s--;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Bug #79265 variation: "host:" not at start of header
3+
--INI--
4+
allow_url_fopen=1
5+
--SKIPIF--
6+
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
7+
--FILE--
8+
<?php
9+
require 'server.inc';
10+
11+
$responses = array(
12+
"data://text/plain,HTTP/1.0 200 OK\r\n\r\n",
13+
);
14+
15+
$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
16+
17+
$opts = array(
18+
'http'=>array(
19+
'method'=>"GET",
20+
'header'=>"RandomHeader: host:8080\r\n" .
21+
"Cookie: foo=bar\r\n"
22+
)
23+
);
24+
$context = stream_context_create($opts);
25+
$fd = fopen('http://127.0.0.1:12342/', 'rb', false, $context);
26+
fseek($output, 0, SEEK_SET);
27+
echo stream_get_contents($output);
28+
fclose($fd);
29+
30+
http_server_kill($pid);
31+
32+
?>
33+
--EXPECT--
34+
GET / HTTP/1.0
35+
Host: 127.0.0.1:12342
36+
Connection: close
37+
RandomHeader: host:8080
38+
Cookie: foo=bar

0 commit comments

Comments
 (0)