Use filter_var for REQUEST_URI

In some cases filter_input returns NULL for server variables even though they are present.
Such as this bug https://bugs.php.net/bug.php?id=49184, though not only in CLI.
At least in our DDEV it happens here.
This commit is contained in:
Alex P 2022-05-23 10:23:06 +03:00
parent 6771d978ec
commit a220396fcc

View file

@ -58,7 +58,8 @@ class CustomerApprovalListener {
return;
}
$url = (string) filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL );
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
$url = (string) filter_var( $_SERVER['REQUEST_URI'] ?? '', FILTER_SANITIZE_URL );
$query = wp_parse_url( $url, PHP_URL_QUERY );
if ( $query && str_contains( $query, 'ppcp_vault=cancel' ) ) {