mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 13:46:48 +00:00
Fix the associativity of boolean logic operators
Change-Id: Icaf0fde0d74064532af4b110faef4014f8303f80
This commit is contained in:
parent
c39169d155
commit
46faa02c49
|
@ -143,7 +143,7 @@ class AFPTreeParser {
|
|||
// Current token handled by the parser and its position.
|
||||
public $mCur, $mPos;
|
||||
|
||||
const CACHE_VERSION = 1;
|
||||
const CACHE_VERSION = 2;
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
|
@ -415,14 +415,14 @@ class AFPTreeParser {
|
|||
protected function doLevelBoolOps() {
|
||||
$leftOperand = $this->doLevelCompares();
|
||||
$ops = [ '&', '|', '^' ];
|
||||
if ( $this->mCur->type == AFPToken::TOP && in_array( $this->mCur->value, $ops ) ) {
|
||||
while ( $this->mCur->type == AFPToken::TOP && in_array( $this->mCur->value, $ops ) ) {
|
||||
$op = $this->mCur->value;
|
||||
$position = $this->mPos;
|
||||
$this->move();
|
||||
|
||||
$rightOperand = $this->doLevelBoolOps();
|
||||
$rightOperand = $this->doLevelCompares();
|
||||
|
||||
return new AFPTreeNode(
|
||||
$leftOperand = new AFPTreeNode(
|
||||
AFPTreeNode::LOGIC,
|
||||
[ $op, $leftOperand, $rightOperand ],
|
||||
$position
|
||||
|
|
1
tests/parserTests/bool-assoc.r
Normal file
1
tests/parserTests/bool-assoc.r
Normal file
|
@ -0,0 +1 @@
|
|||
MATCH
|
1
tests/parserTests/bool-assoc.t
Normal file
1
tests/parserTests/bool-assoc.t
Normal file
|
@ -0,0 +1 @@
|
|||
!(true | false & false)
|
Loading…
Reference in a new issue