From 722c4112196f4989f5328b329581ae5f5e157fac Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 5 Jan 2022 17:46:18 +0000 Subject: [PATCH] Add workaround for when expressions are parsed in masks/patterns where '&&' is used Fixes #1517 --- .../core/extension/factory/parser/FaweParser.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/FaweParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/FaweParser.java index bcd1b0941..11d33ef67 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/FaweParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/FaweParser.java @@ -33,12 +33,14 @@ public abstract class FaweParser extends InputParser implements AliasedPar List inputs = new ArrayList<>(); List and = new ArrayList<>(); int last = 0; - outer: + boolean expression = false; for (int i = 0; i < toParse.length(); i++) { char c = toParse.charAt(i); switch (c) { - case ',': - case '&': + case ',', '&' -> { + if (expression) { + continue; + } String result = toParse.substring(last, i); if (!result.isEmpty()) { inputs.add(result); @@ -47,8 +49,9 @@ public abstract class FaweParser extends InputParser implements AliasedPar throw new InputParseException(Caption.of("fawe.error.parse.invalid-dangling-character", c)); } last = i + 1; - continue outer; - default: + } + case '=' -> expression = true; + default -> { if (c == '[') { int next = StringMan.findMatchingBracket(toParse, i); if (next != -1) { @@ -57,7 +60,9 @@ public abstract class FaweParser extends InputParser implements AliasedPar toParse += "]"; i = toParse.length(); } + expression = false; } + } } } inputs.add(toParse.substring(last));