xref: /PHP-8.1/sapi/cli/tests/bug73630.phpt (revision d7db5701)
1--TEST--
2Bug #73630 (Built-in Weberver - overwrite $_SERVER['request_uri'])
3--SKIPIF--
4<?php
5include "skipif.inc";
6?>
7--FILE--
8<?php
9
10$code = <<<'EOF'
11var_dump(strncmp($_SERVER['REQUEST_URI'], "/overflow.php", strlen("/overflow.php")));
12var_dump(strlen($_SERVER['QUERY_STRING']));
13EOF;
14
15include "php_cli_server.inc";
16php_cli_server_start($code);
17
18$host = PHP_CLI_SERVER_HOSTNAME;
19$fp = php_cli_server_connect();
20
21$path = "/overflow.php?" . str_repeat("x", 16400) . "//example.com";
22
23if (fwrite($fp, <<<HEADER
24GET $path HTTP/1.1
25Host: {$host}
26
27
28HEADER
29)) {
30	while (!feof($fp)) {
31		echo fgets($fp);
32	}
33}
34
35?>
36--EXPECTF--
37HTTP/1.1 200 OK
38Host: %s
39Date: %s
40Connection: close
41X-Powered-By: PHP/%s
42Content-type: text/html; charset=UTF-8
43
44int(0)
45int(16413)
46