hhvm
hhvm copied to clipboard
filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) acts differently than php
HHVM Version
HipHop VM 3.12.0 (rel)
Standalone code, or other way to reproduce the problem
function filterPrivateIP($ipArr) {
// X-Forwaded-For standard is that the first IP in the comma separated list is the true client IP $ips = explode(',', $ipArr); foreach($ips as $ip) { $ip = trim($ip); $ip = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE); if($ip !== FALSE) return $ip; } } $ipArr = '100.8.116.127'; print($ipArr); $filtered = filterPrivateIP($ipArr); echo "\nfiltered: ".$filtered."\n";
Expected result
filtered: 100.8.116.127 (it's the result given by php)
Actual result
filtered:
Looks like it broke in 3.11.0. 3.10.0 seems to get the correct value. https://3v4l.org/UB2kB