Fix #yogosha4512

This commit is contained in:
Laurent Destailleur
2020-09-17 21:34:31 +02:00
parent a895cdcdf8
commit 5744b1e0a3
3 changed files with 39 additions and 3 deletions

View File

@@ -1312,4 +1312,32 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
return true;
}
/**
* testGetUserRemoteIP
*
* @return boolean
*/
public function testGetUserRemoteIP()
{
global $conf, $langs;
$_SERVER['HTTP_X_FORWARDED_FOR']='1.2.3.4';
$_SERVER['HTTP_CLIENT_IP']='5.6.7.8';
$result = getUserRemoteIP();
$this->assertEquals($result, '1.2.3.4');
$_SERVER['HTTP_X_FORWARDED_FOR']='1.2.3.4<corrupted>';
$_SERVER['HTTP_CLIENT_IP']='5.6.7.8';
$result = getUserRemoteIP();
$this->assertEquals($result, '5.6.7.8');
$_SERVER['HTTP_X_FORWARDED_FOR']='[1:2:3:4]';
$_SERVER['HTTP_CLIENT_IP']='5.6.7.8';
$result = getUserRemoteIP();
$this->assertEquals($result, '[1:2:3:4]');
return true;
}
}