[core] don't crash when REMOTE_ADDR is 'unix:', fixes #1076
This commit is contained in:
parent
c5fc001dbd
commit
4cc9b2f5d3
1 changed files with 7 additions and 0 deletions
|
@ -156,6 +156,9 @@ function is_trusted_proxy(): bool
|
|||
}
|
||||
// @phpstan-ignore-next-line - TRUSTED_PROXIES is defined in config
|
||||
foreach(TRUSTED_PROXIES as $proxy) {
|
||||
if($ra === $proxy) { // check for "unix:" before checking IPs
|
||||
return true;
|
||||
}
|
||||
if(ip_in_range($ra, $proxy)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -170,6 +173,10 @@ function get_real_ip(): string
|
|||
{
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
if($ip == "unix:") {
|
||||
$ip = "0.0.0.0";
|
||||
}
|
||||
|
||||
if(is_trusted_proxy()) {
|
||||
if (isset($_SERVER['HTTP_X_REAL_IP'])) {
|
||||
if(filter_var_ex($ip, FILTER_VALIDATE_IP)) {
|
||||
|
|
Reference in a new issue