diff --git a/application/Espo/Core/Formula/Parser.php b/application/Espo/Core/Formula/Parser.php index f96de8ce95..6efa091a70 100644 --- a/application/Espo/Core/Formula/Parser.php +++ b/application/Espo/Core/Formula/Parser.php @@ -861,7 +861,7 @@ class Parser $offset = -1; while (true) { - $index = strrpos($expression, $operator, $offset); + $index = strrpos($modifiedExpression, $operator, $offset); if ($index === false) { break; @@ -882,7 +882,7 @@ class Parser if (strlen($operator) === 1) { if ($index < strlen($expression) - 1) { - $possibleRightOperator = trim($operator . $expression[$index + 1]); + $possibleRightOperator = trim($operator . $modifiedExpression[$index + 1]); } } @@ -898,7 +898,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 66bce1e46d..14a6432829 100644 --- a/tests/unit/Espo/Core/Formula/EvaluatorTest.php +++ b/tests/unit/Espo/Core/Formula/EvaluatorTest.php @@ -1380,4 +1380,16 @@ class EvaluatorTest extends \PHPUnit\Framework\TestCase $this->assertEquals(2, $vars->j);; } + + public function testStringsWithOperator(): void + { + $expression = "\$a = '='"; + + $vars = (object) []; + + /** @noinspection PhpUnhandledExceptionInspection */ + $this->evaluator->process($expression, null, $vars); + + $this->assertEquals("=", $vars->a); + } }