mirror of
https://github.com/php/php-src.git
synced 2024-10-02 23:36:16 +00:00
Merge branch 'PHP-5.5' of https://git.php.net/repository/php-src into PHP-5.5
# By Michael Wallner (2) and Dmitry Stogov (1) # Via Michael Wallner (3) and Christopher Jones (1) * 'PHP-5.5' of https://git.php.net/repository/php-src: fix bug #62396 'make test' crashes starting with 5.3.14 (missing gzencode()) Fixed bug #61548 Reverted patch (it was used for internal testing and was committed by accident)
This commit is contained in:
commit
ec5b87c50d
@ -84,6 +84,30 @@
|
|||||||
#define HTTP_WRAPPER_HEADER_INIT 1
|
#define HTTP_WRAPPER_HEADER_INIT 1
|
||||||
#define HTTP_WRAPPER_REDIRECTED 2
|
#define HTTP_WRAPPER_REDIRECTED 2
|
||||||
|
|
||||||
|
static inline void strip_header(char *header_bag, char *lc_header_bag,
|
||||||
|
const char *lc_header_name)
|
||||||
|
{
|
||||||
|
char *lc_header_start = strstr(lc_header_bag, lc_header_name);
|
||||||
|
char *header_start = header_bag + (lc_header_start - lc_header_bag);
|
||||||
|
|
||||||
|
if (lc_header_start
|
||||||
|
&& (lc_header_start == lc_header_bag || *(lc_header_start-1) == '\n')
|
||||||
|
) {
|
||||||
|
char *lc_eol = strchr(lc_header_start, '\n');
|
||||||
|
char *eol = header_start + (lc_eol - lc_header_start);
|
||||||
|
|
||||||
|
if (lc_eol) {
|
||||||
|
size_t eollen = strlen(lc_eol);
|
||||||
|
|
||||||
|
memmove(lc_header_start, lc_eol+1, eollen);
|
||||||
|
memmove(header_start, eol+1, eollen);
|
||||||
|
} else {
|
||||||
|
*lc_header_start = '\0';
|
||||||
|
*header_start = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context, int redirect_max, int flags STREAMS_DC TSRMLS_DC) /* {{{ */
|
php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context, int redirect_max, int flags STREAMS_DC TSRMLS_DC) /* {{{ */
|
||||||
{
|
{
|
||||||
php_stream *stream = NULL;
|
php_stream *stream = NULL;
|
||||||
@ -425,40 +449,17 @@ finish:
|
|||||||
if (tmp && strlen(tmp) > 0) {
|
if (tmp && strlen(tmp) > 0) {
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if (!header_init) { /* Remove post headers for redirects */
|
|
||||||
int l = strlen(tmp);
|
|
||||||
char *s2, *tmp_c = estrdup(tmp);
|
|
||||||
|
|
||||||
php_strtolower(tmp_c, l);
|
|
||||||
if ((s = strstr(tmp_c, "content-length:"))) {
|
|
||||||
if ((s2 = memchr(s, '\n', tmp_c + l - s))) {
|
|
||||||
int b = tmp_c + l - 1 - s2;
|
|
||||||
memmove(tmp, tmp + (s2 + 1 - tmp_c), b);
|
|
||||||
memmove(tmp_c, s2 + 1, b);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
tmp[s - tmp_c] = *s = '\0';
|
|
||||||
}
|
|
||||||
l = strlen(tmp_c);
|
|
||||||
}
|
|
||||||
if ((s = strstr(tmp_c, "content-type:"))) {
|
|
||||||
if ((s2 = memchr(s, '\n', tmp_c + l - s))) {
|
|
||||||
memmove(tmp, tmp + (s2 + 1 - tmp_c), tmp_c + l - 1 - s2);
|
|
||||||
} else {
|
|
||||||
tmp[s - tmp_c] = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
efree(tmp_c);
|
|
||||||
tmp_c = php_trim(tmp, strlen(tmp), NULL, 0, NULL, 3 TSRMLS_CC);
|
|
||||||
efree(tmp);
|
|
||||||
tmp = tmp_c;
|
|
||||||
}
|
|
||||||
|
|
||||||
user_headers = estrdup(tmp);
|
user_headers = estrdup(tmp);
|
||||||
|
|
||||||
/* Make lowercase for easy comparison against 'standard' headers */
|
/* Make lowercase for easy comparison against 'standard' headers */
|
||||||
php_strtolower(tmp, strlen(tmp));
|
php_strtolower(tmp, strlen(tmp));
|
||||||
|
|
||||||
|
if (!header_init) {
|
||||||
|
/* strip POST headers on redirect */
|
||||||
|
strip_header(user_headers, tmp, "content-length:");
|
||||||
|
strip_header(user_headers, tmp, "content-type:");
|
||||||
|
}
|
||||||
|
|
||||||
if ((s = strstr(tmp, "user-agent:")) &&
|
if ((s = strstr(tmp, "user-agent:")) &&
|
||||||
(s == tmp || *(s-1) == '\r' || *(s-1) == '\n' ||
|
(s == tmp || *(s-1) == '\r' || *(s-1) == '\n' ||
|
||||||
*(s-1) == '\t' || *(s-1) == ' ')) {
|
*(s-1) == '\t' || *(s-1) == ' ')) {
|
||||||
|
118
ext/standard/tests/http/bug61548.phpt
Normal file
118
ext/standard/tests/http/bug61548.phpt
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
--TEST--
|
||||||
|
Bug #61548 (content-type must appear at the end of headers)
|
||||||
|
--INI--
|
||||||
|
allow_url_fopen=1
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require 'server.inc';
|
||||||
|
|
||||||
|
function do_test($header) {
|
||||||
|
$options = [
|
||||||
|
'http' => [
|
||||||
|
'method' => 'POST',
|
||||||
|
'header' => $header,
|
||||||
|
'follow_location' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$ctx = stream_context_create($options);
|
||||||
|
|
||||||
|
$responses = [
|
||||||
|
"data://text/plain,HTTP/1.1 201\r\nLocation: /foo\r\n\r\n",
|
||||||
|
"data://text/plain,HTTP/1.1 200\r\nConnection: close\r\n\r\n",
|
||||||
|
];
|
||||||
|
$pid = http_server('tcp://127.0.0.1:12342', $responses, $output);
|
||||||
|
|
||||||
|
$fd = fopen('http://127.0.0.1:12342/', 'rb', false, $ctx);
|
||||||
|
fseek($output, 0, SEEK_SET);
|
||||||
|
echo stream_get_contents($output);
|
||||||
|
|
||||||
|
http_server_kill($pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
do_test("First:1\nSecond:2\nContent-type: text/plain");
|
||||||
|
do_test("First:1\nSecond:2\nContent-type: text/plain\n");
|
||||||
|
do_test("First:1\nSecond:2\nContent-type: text/plain\nThird:");
|
||||||
|
do_test("First:1\nContent-type:text/plain\nSecond:2");
|
||||||
|
do_test("First:1\nContent-type:text/plain\nSecond:2\n");
|
||||||
|
do_test("First:1\nContent-type:text/plain\nSecond:2\nThird:");
|
||||||
|
|
||||||
|
?>
|
||||||
|
Done
|
||||||
|
--EXPECT--
|
||||||
|
POST / HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Second:2
|
||||||
|
Content-type: text/plain
|
||||||
|
|
||||||
|
GET /foo HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Second:2
|
||||||
|
|
||||||
|
|
||||||
|
POST / HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Second:2
|
||||||
|
Content-type: text/plain
|
||||||
|
|
||||||
|
GET /foo HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Second:2
|
||||||
|
|
||||||
|
|
||||||
|
POST / HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Second:2
|
||||||
|
Content-type: text/plain
|
||||||
|
Third:
|
||||||
|
|
||||||
|
GET /foo HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Second:2
|
||||||
|
Third:
|
||||||
|
|
||||||
|
POST / HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Content-type:text/plain
|
||||||
|
Second:2
|
||||||
|
|
||||||
|
GET /foo HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Second:2
|
||||||
|
|
||||||
|
POST / HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Content-type:text/plain
|
||||||
|
Second:2
|
||||||
|
|
||||||
|
GET /foo HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Second:2
|
||||||
|
|
||||||
|
POST / HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Content-type:text/plain
|
||||||
|
Second:2
|
||||||
|
Third:
|
||||||
|
|
||||||
|
GET /foo HTTP/1.0
|
||||||
|
Host: 127.0.0.1:12342
|
||||||
|
First:1
|
||||||
|
Second:2
|
||||||
|
Third:
|
||||||
|
|
||||||
|
Done
|
||||||
|
|
@ -459,7 +459,7 @@ $pass_options = '';
|
|||||||
$compression = 0;
|
$compression = 0;
|
||||||
$output_file = $CUR_DIR . '/php_test_results_' . date('Ymd_Hi') . '.txt';
|
$output_file = $CUR_DIR . '/php_test_results_' . date('Ymd_Hi') . '.txt';
|
||||||
|
|
||||||
if ($compression) {
|
if ($compression && in_array("compress.zlib", stream_get_filters())) {
|
||||||
$output_file = 'compress.zlib://' . $output_file . '.gz';
|
$output_file = 'compress.zlib://' . $output_file . '.gz';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1548,6 +1548,16 @@ TEST $file
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!extension_loaded("zlib")
|
||||||
|
&& ( array_key_exists("GZIP_POST", $section_text)
|
||||||
|
|| array_key_exists("DEFLATE_POST", $section_text))
|
||||||
|
) {
|
||||||
|
$message = "ext/zlib required";
|
||||||
|
show_result('SKIP', $tested, $tested_file, "reason: $message", $temp_filenames);
|
||||||
|
junit_mark_test_as('SKIP', $shortname, $tested, null, "<![CDATA[\n$message\n]]>");
|
||||||
|
return 'SKIPPED';
|
||||||
|
}
|
||||||
|
|
||||||
if (@count($section_text['REDIRECTTEST']) == 1) {
|
if (@count($section_text['REDIRECTTEST']) == 1) {
|
||||||
$test_files = array();
|
$test_files = array();
|
||||||
|
|
||||||
|
@ -154,7 +154,6 @@ static const opt_struct OPTIONS[] = {
|
|||||||
{'?', 0, "usage"},/* help alias (both '?' and 'usage') */
|
{'?', 0, "usage"},/* help alias (both '?' and 'usage') */
|
||||||
{'v', 0, "version"},
|
{'v', 0, "version"},
|
||||||
{'z', 1, "zend-extension"},
|
{'z', 1, "zend-extension"},
|
||||||
{'W', 1, "warmup"},
|
|
||||||
{'T', 1, "timing"},
|
{'T', 1, "timing"},
|
||||||
{'-', 0, NULL} /* end of args */
|
{'-', 0, NULL} /* end of args */
|
||||||
};
|
};
|
||||||
@ -1755,7 +1754,6 @@ int main(int argc, char *argv[])
|
|||||||
int fcgi_fd = 0;
|
int fcgi_fd = 0;
|
||||||
fcgi_request *request = NULL;
|
fcgi_request *request = NULL;
|
||||||
int repeats = 1;
|
int repeats = 1;
|
||||||
int warmup_repeats = 0;
|
|
||||||
int benchmark = 0;
|
int benchmark = 0;
|
||||||
#if HAVE_GETTIMEOFDAY
|
#if HAVE_GETTIMEOFDAY
|
||||||
struct timeval start, end;
|
struct timeval start, end;
|
||||||
@ -2105,9 +2103,6 @@ consult the installation file that came with this distribution, or visit \n\
|
|||||||
time(&start);
|
time(&start);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'W':
|
|
||||||
warmup_repeats = atoi(php_optarg);
|
|
||||||
break;
|
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
if (request) {
|
if (request) {
|
||||||
@ -2521,24 +2516,12 @@ fastcgi_request_done:
|
|||||||
|
|
||||||
if (!fastcgi) {
|
if (!fastcgi) {
|
||||||
if (benchmark) {
|
if (benchmark) {
|
||||||
if (warmup_repeats) {
|
repeats--;
|
||||||
warmup_repeats--;
|
if (repeats > 0) {
|
||||||
if (!warmup_repeats) {
|
script_file = NULL;
|
||||||
#ifdef HAVE_GETTIMEOFDAY
|
php_optind = orig_optind;
|
||||||
gettimeofday(&start, NULL);
|
php_optarg = orig_optarg;
|
||||||
#else
|
|
||||||
time(&start);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
repeats--;
|
|
||||||
if (repeats > 0) {
|
|
||||||
script_file = NULL;
|
|
||||||
php_optind = orig_optind;
|
|
||||||
php_optarg = orig_optarg;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user