Skip to content

Commit 4ae8e6a

Browse files
committed
Throw error if float or integer is out of range
1 parent 0c88682 commit 4ae8e6a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/JsonPathEvaluator.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,30 @@ protected function evaluateLogicalExpressionNode(
712712
}
713713

714714
if ($astNode instanceof IntegerNode) {
715+
if ($astNode->token->value > (string)PHP_INT_MAX || $astNode->token->value < (string)PHP_INT_MIN) {
716+
throw new JsonPathEvaluationException(
717+
'Integer is out of range (possible range from ' . PHP_INT_MIN . ' to ' . PHP_INT_MAX . ')',
718+
$astNode->token->position,
719+
$evaluationContext->expression,
720+
1702863910
721+
);
722+
}
723+
715724
return (int)$astNode->token->value;
716725
}
717726

718727
if ($astNode instanceof FloatNode) {
728+
$float = floatval($astNode->token->value);
729+
730+
if ($float === INF || $float === -INF) {
731+
throw new JsonPathEvaluationException(
732+
'Float is out of range (possible range from ' . PHP_FLOAT_MIN . ' to ' . PHP_FLOAT_MAX . ')',
733+
$astNode->token->position,
734+
$evaluationContext->expression,
735+
1702863907
736+
);
737+
}
738+
719739
return (float)$astNode->token->value;
720740
}
721741

0 commit comments

Comments
 (0)