From c13545527faa6c0b74c93fc731bffa862f68aefd Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Wed, 29 Jan 2020 15:13:12 +0100 Subject: [PATCH] Fix Calc --- src/Calc/Calc.php | 6 +++++- src/Calc/CalcValues.php | 9 +++++++-- tests/Customer/A/formels.txt | 6 +++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Calc/Calc.php b/src/Calc/Calc.php index 417daec..523b6d8 100644 --- a/src/Calc/Calc.php +++ b/src/Calc/Calc.php @@ -85,7 +85,11 @@ class Calc if($collection->getName() == "opt") continue; if($collection->getFormel() != "") { $formel = $this->formelCalc->parse($collection->getFormel()); - eval('$var = ' . $formel . ';'); + if(preg_match("/^[a-z](.*)/", $formel)) { + eval('$var = "' . $formel . '";'); + }else{ + eval('$var = ' . $formel . ';'); + } }else{ if(!isset($this->engine->getVariables()[$collection->getName()])) { $var = 'XXXXXXXXXXXX'; diff --git a/src/Calc/CalcValues.php b/src/Calc/CalcValues.php index 9dc95b9..1febd14 100644 --- a/src/Calc/CalcValues.php +++ b/src/Calc/CalcValues.php @@ -90,7 +90,12 @@ class CalcValues if($collection->getName() == "opt") continue; if($collection->getFormel() != "") { $formel = $this->formelCalc->parse($collection->getFormel()); - eval('$var = ' . $formel . ';'); + if(preg_match("/^[a-z](.*)/", $formel)) { + eval('$var = "' . $formel . '";'); + }else{ + eval('$var = ' . $formel . ';'); + } + }else{ if(!isset($this->engine->getVariables()[$collection->getName()])) { $var = 'XXXXXXXX'; @@ -126,4 +131,4 @@ class CalcValues return $price; } -} \ No newline at end of file +} diff --git a/tests/Customer/A/formels.txt b/tests/Customer/A/formels.txt index 42fb7de..b71179f 100644 --- a/tests/Customer/A/formels.txt +++ b/tests/Customer/A/formels.txt @@ -693,10 +693,10 @@ if(!function_exists('getSammelformMengenAbschlagPlano')) { function getMaschine($breite, $hoehe) { if($breite > 49 || $hoehe > 49) { - return '"kba"'; + return 'kba'; } - return '"gto"'; + return 'gto'; } function getGeiferRand($format) { @@ -730,4 +730,4 @@ if(!function_exists('getSammelformMengenAbschlagPlano')) { } -} \ No newline at end of file +}