Welcome Guest, Not a member yet? Register   Sign In
function Input::valid_ip() works not proper if ip contains empty segments
#1

[eluser]Unknown[/eluser]
The function Input::valid_ip($ip) does not proper recognize IP with empty segments like valid.

Example of code:

Code:
echo $this->input->valid_ip('172.167..255') ? 'valid' : 'not valid';

Expected Result: not valid
Actual Result: valid

To fix it need change line 408 in system/libraries/Input.php:

Code:
if (preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)

to:

Code:
if (preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3 OR strlen($segment) == 0)




Theme © iAndrew 2016 - Forum software by © MyBB