Skip to content

Commit

Permalink
Dev: Revert "Fixed issue: Comparing two string with greater-than oper…
Browse files Browse the repository at this point in the history
…ation fails"

Dev: This reverts commit efa8a10.
  • Loading branch information
olleharstedt committed Oct 15, 2019
1 parent 0dee716 commit 99ffa7d
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions application/helpers/expressions/em_core_helper.php
Expand Up @@ -319,19 +319,6 @@ public function RDP_EvaluateBinary(array $token)
return false;
}

/**
* PHP and JS type cast differently when doing "2" > "18".
* Easiest solution is to ban compare < and > when both args are strings.
*/
$stringTypes = array('DQ_STRING', 'DS_STRING', 'WORD');
if ($token[2] === 'COMPARE'
&& $token[0] != '==' // Allow equality compare
&& $token[0] != '!='
&& (in_array($arg1[2], $stringTypes) && in_array($arg2[2], $stringTypes))) {
$this->RDP_AddError(self::gT("It's not allowed to compare two strings with 'higher than'/'lower than', only numbers. Use intval() to cast a string to a number, or make sure a hard-coded number is not written inside quotes. To compare two strings alpabetically, use the function strcmp()."), $token);
return false;
}

list($bMismatchType, $bBothNumeric, $bBothString) = $this->getMismatchInformation($arg1, $arg2);

// Set bBothString if one is forced to be string, only if both can be numeric. Mimic JS and PHP
Expand Down Expand Up @@ -704,7 +691,7 @@ private function RDP_EvaluateExpression()
* @return boolean - true if success, false if any error occurred
*/

private function RDP_EvaluateExpressions()
private function RDP_EvaluateExpressions()
{
$evalStatus = $this->RDP_EvaluateExpression();
if (!$evalStatus) {
Expand Down Expand Up @@ -2255,9 +2242,9 @@ private function RDP_Tokenize($sSource, $bOnEdit = false)

// $aInitTokens = array of tokens from equation, showing value and offset position. Will include SPACE.
if ($bOnEdit) {
$aInitTokens = preg_split($this->RDP_TokenizerRegex, $sSource, -1, (PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE));
$aInitTokens = preg_split($this->RDP_TokenizerRegex, $sSource, -1, (PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE));
} else {
$aInitTokens = preg_split($this->RDP_TokenizerRegex, $sSource, -1, (PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE));
$aInitTokens = preg_split($this->RDP_TokenizerRegex, $sSource, -1, (PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE));
}

// $aTokens = array of tokens from equation, showing value, offsete position, and type. Will not contain SPACE if !$bOnEdit, but will contain OTHER
Expand Down

0 comments on commit 99ffa7d

Please sign in to comment.