mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-09-23 18:28:20 +00:00
Merge "Fix validation for ip_in_ranges"
This commit is contained in:
commit
00ad47bab3
|
@ -90,7 +90,7 @@ class FilterEvaluator {
|
|||
'rcount' => [ 1, 2 ],
|
||||
'get_matches' => [ 2, 2 ],
|
||||
'ip_in_range' => [ 2, 2 ],
|
||||
'ip_in_ranges' => [ 3, INF ],
|
||||
'ip_in_ranges' => [ 2, INF ],
|
||||
'contains_any' => [ 2, INF ],
|
||||
'contains_all' => [ 2, INF ],
|
||||
'equals_to_any' => [ 2, INF ],
|
||||
|
@ -1022,6 +1022,7 @@ class FilterEvaluator {
|
|||
protected function funcIPInRanges( $args, int $position ) {
|
||||
$ip = array_shift( $args )->toString();
|
||||
|
||||
$strRanges = [];
|
||||
foreach ( $args as $range ) {
|
||||
$range = $range->toString();
|
||||
|
||||
|
@ -1033,12 +1034,10 @@ class FilterEvaluator {
|
|||
);
|
||||
}
|
||||
|
||||
if ( IPUtils::isInRange( $ip, $range ) ) {
|
||||
return new AFPData( AFPData::DBOOL, true );
|
||||
}
|
||||
$strRanges[] = $range;
|
||||
}
|
||||
|
||||
return new AFPData( AFPData::DBOOL, false );
|
||||
return new AFPData( AFPData::DBOOL, IPUtils::isInRanges( $ip, $strRanges ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -576,6 +576,7 @@ class ParserTest extends ParserTestCase {
|
|||
return [
|
||||
[ "ip_in_range('0.0.0.0', 'lol')", 'funcIPInRange' ],
|
||||
[ "ip_in_ranges('0.0.0.0', ':', '0.0.0.256')", 'funcIPInRanges' ],
|
||||
[ "ip_in_ranges('1.1.1.1', '1.1.0.0/16', 'gibberish')", 'funcIPInRanges' ],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -645,6 +646,7 @@ class ParserTest extends ParserTestCase {
|
|||
return [
|
||||
[ 'get_matches' ],
|
||||
[ 'ip_in_range' ],
|
||||
[ 'ip_in_ranges' ],
|
||||
[ 'contains_any' ],
|
||||
[ 'contains_all' ],
|
||||
[ 'ccnorm_contains_any' ],
|
||||
|
@ -680,7 +682,6 @@ class ParserTest extends ParserTestCase {
|
|||
public function threeParamsFuncs() {
|
||||
return [
|
||||
[ 'str_replace' ],
|
||||
[ 'ip_in_ranges' ],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue