1
0
mirror of https://github.com/php/php-src.git synced 2026-04-01 21:22:13 +02:00

Merge branch 'PHP-7.3' into PHP-7.4

* PHP-7.3:
  Don't treat any WS as start of header
This commit is contained in:
Nikita Popov
2020-02-24 10:20:43 +01:00
2 changed files with 40 additions and 3 deletions

View File

@@ -108,7 +108,7 @@ static inline void strip_header(char *header_bag, char *lc_header_bag,
static zend_bool check_has_header(const char *headers, const char *header) {
const char *s = headers;
while ((s = strstr(s, header))) {
if (s == headers || *(s-1) == '\r' || *(s-1) == '\n' || *(s-1) == '\t' || *(s-1) == ' ') {
if (s == headers || *(s-1) == '\n') {
return 1;
}
s++;
@@ -494,8 +494,7 @@ finish:
/* remove Proxy-Authorization header */
if (use_proxy && use_ssl && (s = strstr(t, "proxy-authorization:")) &&
(s == t || *(s-1) == '\r' || *(s-1) == '\n' ||
*(s-1) == '\t' || *(s-1) == ' ')) {
(s == t || *(s-1) == '\n')) {
char *p = s + sizeof("proxy-authorization:") - 1;
while (s > t && (*(s-1) == ' ' || *(s-1) == '\t')) s--;

View File

@@ -0,0 +1,38 @@
--TEST--
Bug #79265 variation: "host:" not at start of header
--INI--
allow_url_fopen=1
--SKIPIF--
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
--FILE--
<?php
require 'server.inc';
$responses = array(
"data://text/plain,HTTP/1.0 200 OK\r\n\r\n",
);
$pid = http_server("tcp://127.0.0.1:12342", $responses, $output);
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"RandomHeader: host:8080\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
$fd = fopen('http://127.0.0.1:12342/', 'rb', false, $context);
fseek($output, 0, SEEK_SET);
echo stream_get_contents($output);
fclose($fd);
http_server_kill($pid);
?>
--EXPECT--
GET / HTTP/1.0
Host: 127.0.0.1:12342
Connection: close
RandomHeader: host:8080
Cookie: foo=bar