Victor Vasiliev has uploaded a new change for review.
https://gerrit.wikimedia.org/r/320157
Change subject: Fix the associativity of boolean logic operators
......................................................................
Fix the associativity of boolean logic operators
Change-Id: Icaf0fde0d74064532af4b110faef4014f8303f80
---
M AbuseFilter.parser.new.php
A tests/parserTests/bool-assoc.r
A tests/parserTests/bool-assoc.t
3 files changed, 6 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AbuseFilter
refs/changes/57/320157/1
diff --git a/AbuseFilter.parser.new.php b/AbuseFilter.parser.new.php
index 82afcbe..af7911a 100644
--- a/AbuseFilter.parser.new.php
+++ b/AbuseFilter.parser.new.php
@@ -143,7 +143,7 @@
// 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 @@
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
diff --git a/tests/parserTests/bool-assoc.r b/tests/parserTests/bool-assoc.r
new file mode 100644
index 0000000..4736e08
--- /dev/null
+++ b/tests/parserTests/bool-assoc.r
@@ -0,0 +1 @@
+MATCH
diff --git a/tests/parserTests/bool-assoc.t b/tests/parserTests/bool-assoc.t
new file mode 100644
index 0000000..4b236bd
--- /dev/null
+++ b/tests/parserTests/bool-assoc.t
@@ -0,0 +1 @@
+!(true | false & false)
--
To view, visit https://gerrit.wikimedia.org/r/320157
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icaf0fde0d74064532af4b110faef4014f8303f80
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: Victor Vasiliev <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits