mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 21:53:35 +00:00
Merge "Check for 0-like floats passed to the modulo operator"
This commit is contained in:
commit
91bc961712
|
@ -312,7 +312,10 @@ class AFPData {
|
|||
|
||||
$b = $b->toNumber();
|
||||
|
||||
if ( $op !== '*' && (float)$b === 0.0 ) {
|
||||
if (
|
||||
( $op === '/' && (float)$b === 0.0 ) ||
|
||||
( $op === '%' && (int)$b === 0 )
|
||||
) {
|
||||
$lhs = $this->type === self::DUNDEFINED ? 0 : $this->toNumber();
|
||||
throw new AFPUserVisibleException( 'dividebyzero', $pos, [ $lhs ] );
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class AFPDataTest extends AbuseFilterParserTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Data provider for testRegexFailureException
|
||||
* Data provider for testDivideByZeroException
|
||||
* The second parameter is the function where the exception is raised.
|
||||
* One expression for each throw.
|
||||
*
|
||||
|
@ -60,6 +60,11 @@ class AFPDataTest extends AbuseFilterParserTestCase {
|
|||
return [
|
||||
[ '1/0', 'mulRel' ],
|
||||
[ '1/0.0', 'mulRel' ],
|
||||
[ '1/(-0.0)', 'mulRel' ],
|
||||
[ '1%0', 'mulRel' ],
|
||||
[ '1%0.0', 'mulRel' ],
|
||||
[ '1%0.3', 'mulRel' ],
|
||||
[ '1%(-0.7)', 'mulRel' ],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue