1--TEST--
2FPM: bug72573 - HTTP_PROXY - CVE-2016-5385
3--SKIPIF--
4<?php include "skipif.inc"; ?>
5--FILE--
6<?php
7
8require_once "tester.inc";
9
10$cfg = <<<EOT
11[global]
12error_log = {{FILE:LOG}}
13[unconfined]
14listen = {{ADDR}}
15pm = dynamic
16pm.max_children = 5
17pm.start_servers = 1
18pm.min_spare_servers = 1
19pm.max_spare_servers = 3
20EOT;
21
22$code = <<<EOT
23<?php
24echo "Test Start\n";
25var_dump(
26    @\$_SERVER["HTTP_PROXY"],
27    \$_SERVER["HTTP_FOO"],
28    getenv("HTTP_PROXY"),
29    getenv("HTTP_FOO")
30);
31echo "Test End\n";
32EOT;
33
34$tester = new FPM\Tester($cfg, $code);
35$tester->start();
36$tester->expectLogStartNotices();
37$tester
38    ->request(
39        '',
40        [
41            'HTTP_FOO' => 'BAR',
42            'HTTP_PROXY' => 'BADPROXY',
43        ]
44    )
45    ->expectBody(
46        [
47            'Test Start',
48            'NULL',
49            'string(3) "BAR"',
50            'bool(false)',
51            'string(3) "BAR"',
52            'Test End'
53        ]
54    );
55$tester->terminate();
56$tester->close();
57
58?>
59Done
60--EXPECT--
61Done
62--CLEAN--
63<?php
64require_once "tester.inc";
65FPM\Tester::clean();
66?>
67