diff --git a/application/Espo/Core/Formula/Parser.php b/application/Espo/Core/Formula/Parser.php index fa65a8eb94..13d63f1005 100644 --- a/application/Espo/Core/Formula/Parser.php +++ b/application/Espo/Core/Formula/Parser.php @@ -868,7 +868,7 @@ class Parser $offset = -1; while (true) { - $index = strrpos($expression, $operator, $offset); + $index = strrpos($modifiedExpression, $operator, $offset); if ($index === false) { break; @@ -889,7 +889,7 @@ class Parser if (strlen($operator) === 1) { if ($index < strlen($expression) - 1) { - $possibleRightOperator = trim($operator . $expression[$index + 1]); + $possibleRightOperator = trim($operator . $modifiedExpression[$index + 1]); } } @@ -905,7 +905,7 @@ class Parser if (strlen($operator) === 1) { if ($index > 0) { - $possibleLeftOperator = trim($expression[$index - 1] . $operator); + $possibleLeftOperator = trim($modifiedExpression[$index - 1] . $operator); } } diff --git a/tests/unit/Espo/Core/Formula/EvaluatorTest.php b/tests/unit/Espo/Core/Formula/EvaluatorTest.php index e3ff07f0d0..3ae7abd348 100644 --- a/tests/unit/Espo/Core/Formula/EvaluatorTest.php +++ b/tests/unit/Espo/Core/Formula/EvaluatorTest.php @@ -1568,4 +1568,16 @@ class EvaluatorTest extends TestCase /** @noinspection PhpUnhandledExceptionInspection */ $this->evaluator->processSafe($expression); } + + public function testStringsWithOperator(): void + { + $expression = "\$a = '='"; + + $vars = (object) []; + + /** @noinspection PhpUnhandledExceptionInspection */ + $this->evaluator->process($expression, null, $vars); + + $this->assertEquals("=", $vars->a); + } }