27chan / bazukachan

Keeping Vichan alive
https://27chan.org
Other
16 stars 4 forks source link

Fixes faulty regex in validate_ip_string function #23

Closed perdedora closed 1 year ago

perdedora commented 1 year ago

The current implementation only works when an ip is less than 31 characters, if the ip exceed 31 characters, the function returns true

Test code:

$ip[] = 'FRwJzgDIOhfekjtPqFzobWAyZ2Z3Dma'; // valid ip (31 chars). function returns true
$ip[] = 'FRwJzgDIOhfekjdddtPqFzobWAyZ2Z3Dma'; // invalid ip (34 chars). function returns true
$ip[] = 'FRwJzgDIOhfekPqFzobWAyZ2Z3Dma'; // invalid ip (29 chars). function returns false 
foreach($ip as $i)
    var_dump(validate_ip_string($i));