Skip to content

Commit c800c04

Browse files
committed
Replace filter_input(INPUT_SERVER because buggy
1 parent 1c577f6 commit c800c04

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/RequestGlobalsContext.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,16 @@ final class RequestGlobalsContext implements NonceContextInterface
3131
private $context;
3232

3333
/**
34-
* Constructor.
35-
*
3634
* We don't use `$_REQUEST` because, by default, in PHP it gives precedence to `$_GET` over
3735
* `$_POST` in POST requests, and being dependant on `request_order` / `variables_order` ini
3836
* configurations it is not consistent across systems.
3937
*/
4038
public function __construct()
4139
{
42-
$http_method = filter_input(INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING);
40+
$http_method = empty($_SERVER['REQUEST_METHOD']) ? null : $_SERVER['REQUEST_METHOD'];
41+
$is_post = is_string($http_method) && strtoupper($http_method) === 'POST';
42+
$request = $is_post ? array_merge($_GET, $_POST) : $_REQUEST;
4343

44-
$request = strtoupper($http_method) === 'POST' ? array_merge($_GET, $_POST) : $_GET;
4544
$this->context = new ArrayContext($request);
4645
}
4746

0 commit comments

Comments
 (0)