Fix cidr_match() for IPv6 with PHP 7.1
With PHP 7.1 implicit conversion of non-trimmed strings to integer raises an error. Input value fpr IPv6 subnets is now trimmed and a check for numeric value is added.
This commit is contained in:
parent
5f2d883186
commit
3206da2861
@ -287,7 +287,13 @@ class StatifyBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( false !== strpos( $net, '/' ) ) { // Parse CIDR subnet.
|
if ( false !== strpos( $net, '/' ) ) { // Parse CIDR subnet.
|
||||||
list( $base, $mask ) = explode( '/', $net, 2 );
|
list( $base, $mask ) = explode( '/', trim( $net ), 2 );
|
||||||
|
|
||||||
|
if ( ! is_numeric( $mask ) ) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
$mask = (int) $mask;
|
||||||
|
}
|
||||||
|
|
||||||
if ( $mask < 1 || $mask > 128 ) {
|
if ( $mask < 1 || $mask > 128 ) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user